Skip to content

feat: add hidesuggestions property to textbox#17815

Merged
MrJul merged 5 commits intoAvaloniaUI:masterfrom
jcsawyer:master
Jan 22, 2025
Merged

feat: add hidesuggestions property to textbox#17815
MrJul merged 5 commits intoAvaloniaUI:masterfrom
jcsawyer:master

Conversation

@jcsawyer
Copy link
Copy Markdown
Contributor

@jcsawyer jcsawyer commented Dec 21, 2024

What does the pull request do?

Add a ShowSuggestions property to TextInputOptions that when set to false on a text box, the keyboard does not show the autocomplete/word suggestions above the keyboard on Android/iOS.

What is the updated/expected behavior with this PR?

Android/iOS keyboards do not present suggestions when the new ShowSuggestions property is set to false.

Checklist

  • Added unit tests (if possible)? (please tell me if there's tests I'm missing here...)
  • Added XML documentation to any related classes?
  • Consider submitting a PR to https://github.com/AvaloniaUI/avalonia-docs with user documentation

Breaking changes

Fixed issues

Fixes #16579

@avaloniaui-bot
Copy link
Copy Markdown

You can test this PR using the following package version. 11.3.999-cibuild0054061-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@cla-avalonia
Copy link
Copy Markdown
Collaborator

cla-avalonia commented Dec 21, 2024

  • All contributors have signed the CLA.

@jcsawyer
Copy link
Copy Markdown
Contributor Author

@cla-avalonia agree

@MrJul MrJul added enhancement needs-api-review The PR adds new public APIs that should be reviewed. labels Dec 23, 2024
@avaloniaui-bot
Copy link
Copy Markdown

You can test this PR using the following package version. 11.3.999-cibuild0054081-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@avaloniaui-bot
Copy link
Copy Markdown

You can test this PR using the following package version. 11.3.999-cibuild0054114-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@avaloniaui-bot
Copy link
Copy Markdown

You can test this PR using the following package version. 11.3.999-cibuild0054279-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@MrJul
Copy link
Copy Markdown
Member

MrJul commented Jan 15, 2025

API diff for review:

 namespace Avalonia.Input.TextInput
 {
     public class TextInputOptions
     {
+        public static readonly AttachedProperty<System.Boolean> HideSuggestionsProperty;
+        public System.Boolean HideSuggestions { get { throw null; } set { } } 
+        public static System.Boolean GetHideSuggestions(StyledElement avaloniaObject) { throw null; }
+        public static void SetHideSuggestions(StyledElement avaloniaObject, System.Boolean value) { }
     }
 }

Copy link
Copy Markdown
Member

@MrJul MrJul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Notes from the API review meeting:

The default behavior varies by platform: suggestions are enabled by default on mobile and disabled on desktop. This requires a default state, with a nullable boolean, and null being the default value.

Plus, the negative name isn't ideal, so we chose to go with ShowSuggestions instead.

Expected API:

public class TextInputOptions
{
    public static readonly AttachedProperty<bool?> ShowSuggestionsProperty;
    public bool? ShowSuggestions { get; set; } 
    public static bool? GetShowSuggestions(StyledElement);
    public static void SetShowSuggestions(StyledElement, bool?);
}

@MrJul MrJul added api-change-requested The new public APIs need some changes. and removed needs-api-review The PR adds new public APIs that should be reviewed. labels Jan 21, 2025
@avaloniaui-bot
Copy link
Copy Markdown

You can test this PR using the following package version. 11.3.999-cibuild0054387-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@jcsawyer
Copy link
Copy Markdown
Contributor Author

API updated according to specified.

Copy link
Copy Markdown
Member

@MrJul MrJul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few minor points and this is good to go!

Comment thread src/Android/Avalonia.Android/Platform/Input/AndroidInputMethod.cs
Comment thread src/Avalonia.Base/Input/TextInput/TextInputOptions.cs Outdated
Comment thread src/iOS/Avalonia.iOS/TextInputResponder.Properties.cs Outdated
Comment thread src/iOS/Avalonia.iOS/TextInputResponder.Properties.cs Outdated
Copy link
Copy Markdown
Member

@MrJul MrJul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you!

@MrJul MrJul enabled auto-merge January 21, 2025 21:24
@avaloniaui-bot
Copy link
Copy Markdown

You can test this PR using the following package version. 11.3.999-cibuild0054405-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@MrJul MrJul added this pull request to the merge queue Jan 22, 2025
Merged via the queue into AvaloniaUI:master with commit b45872e Jan 22, 2025
@MrJul MrJul added feature and removed enhancement labels Jan 23, 2025
@MrJul MrJul removed the api-change-requested The new public APIs need some changes. label Feb 2, 2025
@MrJul MrJul added the api-approved The new public APIs have been approved. label Feb 2, 2025
Numpsy added a commit to Numpsy/Avalonia.FuncUI that referenced this pull request Feb 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api-approved The new public APIs have been approved. feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Disable text input suggestions and auto-complete

4 participants