-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Allow search page widget search field hint text and keyboard text input action to be customizable #28807
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
justinmc
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@somarkoe Thanks for submitting this and sorry for the lack of reviewers. Looks like a simple improvement to make Search a lot more useful, I'm all on board.
Just a discussion below to decide the best way to do this. There was a Linux test failing, but I think it was flaky so I reran it. We'll see.
|
While you're at it, please do keyboardType: #29983 |
|
I agree with the idea to add keyboardType to this as well. Looks like all tests are passing now. @somarkoe are you still available to get this PR in? |
|
Yes! Sorry, been swamped by work and haven't touched the project that deals with this in a while. I'll add the keyboard type request to it as well. |
|
Awesome, thank you @somarkoe. Update the PR when you get a chance and I'll be happy to help you get this in. |
|
Yeah that one looks straightforward to me. The original reviewer @HansMuller isn't around today but I'll talk it through with him when he's back. |
|
Abandoned? :( |
|
Oops, been a while since I've used git. Reopened and made the relevant changes. Sorry it took so long! |
|
😍 merge this ish! |
|
@somarkoe Thanks for following up and no worries about the delay! Sorry to drag this out longer, but I realized that this should update the tests as well. This test should probably say "keyboard shows search button by default" now. Then, could you add a separate test that tests a different After that this is good to go and we can merge. |
|
@MichaelPriebe I'll try to see if we can get things moving on those 2 other PRs you referenced. |
|
@justinmc how's this going? |
|
Waiting on @somarkoe for the changes mentioned above. Should be quick changes though. |
|
@somarkoe come thru |
e52b10a to
36bb89a
Compare
|
@justinmc What do you think? |
…action, and keyboard text input type to be customizable. [Description] Currently, the search page widget's hint text and keyboard text input action are hardcoded to the material localization of 'Search' and the search text input action, respectively, and the text input type defaults to that defined in `TextField`. This prevents further customization where search functionality is desired, but the nuance of the action isn't exactly "searching" (e.g. adding a location via Google Maps Places API autocomplete). [Changes] Added `hintText`, `textInputAction`, and `keyboardType` fields to `SearchDelegate`. These default to the previous hardcoded attributes that were present in `SearchPage` (or `null`). [Testing] Added a new unit test to cover the new `textInputAction` case (and modified the existing one's name to indicate it's the default behavior). All existing tests still pass, as well.
|
I made the fields non-final since apparently overriding fields when a class is extended is no bueno, and this abstract class is one meant to be extended and not implemented (since it has functions with default behaviors). |
|
Excited for this, can finally ditch my very hacky extension of the search delegate. |
|
@justinmc Is it ready now? |
|
Lets get this pull a'mergin'! |
justinmc
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the delay! I talked to @HansMuller to get some tips for the non-final problem.
| /// for another [showSearch] call. | ||
| abstract class SearchDelegate<T> { | ||
|
|
||
| /// The type of action button to use for the keyboard. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could keep the fields final by using a constructor instead like this:
const SearchDelegate({
this.keyboardType,
this.hintText,
this.textInputAction = TextInputAction.search,
});Then below, make all of the fields final and remove the default assignment from textInputAction.
| if (textInputAction != null) { | ||
| this.textInputAction = textInputAction; | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then with the change in my other comment, you can user super here:
...
}) : super(
textInputAction: textInputAction,
);|
@somarkoe What do you think about the suggestions? |
|
@somarkoe Would love to hear what you think about the suggested changes. |
|
So sorry! Was on vacation and now I'm moving 😅 Ill take a look ASAP! |
|
I'm going to close this since #36409 has been merged. Thank you @somarkoe for your initial work with this! |
Description
Currently, the search page widget's hint text and keyboard text input action are hardcoded to the material localization of 'Search' and the search text input action, respectively. This prevents further customization where search functionality is desired, but the nuance of the action isn't exactly "searching" (e.g. adding a location via Google Maps Places API autocomplete).
Added a
getHintTextfunction (that takes in aBuildContext) and atextInputActionfield toSearchDelegate. These default to the previous hardcoded attributes that were present inSearchPage.These changes are purely aesthetic changes; no additional functionality is provided.
All tests still pass.
Related Issues
N/A
Checklist
Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes (
[x]). This will ensure a smooth and quick review process.///).flutter analyze --flutter-repo) does not report any problems on my PR.Breaking Change
Does your PR require Flutter developers to manually update their apps to accommodate your change?