-
Notifications
You must be signed in to change notification settings - Fork 350
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
[Feature] Keyboard focus remains in text field while changing selection #579
Comments
Hi, Thank you for your issue. The current approach is unfortunately rather janky, as we need to two-way sync state and focus and it becomes very tedious to enforce this without ending up in endless loops. Looking at "Selection" is therefore not related to the item which is currently focused. Focus is only meant to allow users to navigate selecting items via keyboard. I believe it is better if the package stays agnostic to how the The I could imagine adding an option to disable What would be your preferred outcome? |
Hi @clragon, Sorry, I think I've used the wrong terminology - I'm not actually talking about selection, rather highlighting the option which will become selected when the user presses enter. The list of options displayed in the popover has a currently-highlighted option which is implemented using keyboard focus. My feature request, and my preferred outcome, is: retain keyboard focus in the textarea at all times and maintain the currently-highlighted item using internal state, e.g. an index. |
It's implemented using |
Thank you for this information. I was not aware that Autocomplete manually implements this, very interesting. |
The current way that focus is implemented in the TypeAhead package as of its latest version does indeed seem to cause a lot of trouble. I think we will swap over to the same technique that Autocomplete is using to rectify all this and in the process simplify a lot of the code. Hopefully I'll find time for that soon. This change might also come with some more freedom so we can fix some other complaints as well. |
Thank you for your extensive amount of patience. I have now implemented this feature on the master branch. There is probably still some more work needed there, and more of the focus controlling code that I have previously written can be removed now that this new mechanic is in place. If you would like to, please try out these changes and let me know if they serve your needs. |
For myself, heres a quick note:
|
@clragon any update when the version 6 is released, or need any help before releasing it? |
Preferrably I would like to implement #577 before releasing version 6, as it might also contain breaking changes. This will probably take some time. |
The reason we are holding back the release to address #579 first, is because it contains potentially breaking changes to the API surface. While #555 is an unfortunate bug, it is just a bug and fixing it will most likely be a patch version at a later date, as it does not require any changes on behalf of the package users. Version 6 will therefore not address #555 or any other currently open bugs, if not already explicitly stated. Thanks! |
Thanks for explaining @clragon, wish you all the best for the updates ❤️ |
Use case
My primary use case is on Mac where traversing a form using the keyboard is important, and the focus traversal strategy implemented currently does not follow established convention and makes it hard to move keyboard focus to the next input in a form.
Specifically, it's very unusual in common autocomplete implementations for keyboard focus to traverse the list of selections when the user presses up or down. This prevents the user from continuing to type unless they return focus to the input themselves. Even worse, when the suggestions menu is open, pressing tab will currently move focus to the first element in the list instead of to the next input in the form.
This behavior is baked into the
_SuggestionsBoxTraversalConnectorState
which callsnode.focusInDirection(TraversalDirection.up)
(and down). It's impossible to work around this from outside.Proposal
I'd like
flutter_typeahead
to maintain selection state, modify it using keyboard shortcuts/actions and use pass the selection state to the widget responsible for rendering the list items (which is the approach taken by Flutter's built-inAutocomplete
widget, incidentally). And retain keyboard focus in the text input at all times.The text was updated successfully, but these errors were encountered: