Comments (5)
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.
We might make it easier to customize even more of the field.
from flutter_typeahead.
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. flutter_typeahead
moves the highlight up or down the list when the user presses the arrow keys by calling node.focusInDirection()
.
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.
from flutter_typeahead.
I could also imagine looking closer into how autocomplete achieves their way of up and down arrow key selection while not intercepting tab and trying to recreate this here.
It's implemented using Shortcuts
. See the relevant code here: https://github.com/flutter/flutter/blob/3.19.5/packages/flutter/lib/src/widgets/autocomplete.dart#L577-L580
from flutter_typeahead.
Thank you for this information. I was not aware that Autocomplete manually implements this, very interesting.
I can imagine that we could follow suit on this and remove the complex focus code I have written - since it is unsightly.
I will look into this.
from flutter_typeahead.
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 Autocomplete
, it doesnt seem like it keeps track of a selected entry in any way, rather, it calls onSelected
exactly when the user interacts with one of the the items. This is equivalent to TypeAheadField.onSelected
.
"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 onSelected
callback is used and the user keeps track of what item was last selected themselves, if necessary. There are many use-cases where this would not be required.
The Autocomplete
widget also allows users to navigate the list of suggestions via up and down keyboard keys.
It does however not intercept Tab, allowing users to move to the next field.
I could imagine adding an option to disable _SuggestionsBoxTraversalConnectorState
's behaviour, therefore making selection via up and down keys no longer possible.
I could also imagine looking closer into how autocomplete achieves their way of up and down arrow key selection while not intercepting tab and trying to recreate this here.
What would be your preferred outcome?
from flutter_typeahead.
Related Issues (20)
- [Feature] library should also export src/common/base/types.dart HOT 1
- How can i give the hint text and style HOT 3
- [Bug] Adding the TypeAhead widget inside a datatable breaks the flow when using keyboard navigation HOT 2
- [Bug] Keyboard up arrow skips multiple items in list on desktop HOT 1
- Cannot apply border to InkWell in material defaults HOT 1
- Mouse cursor doesn't change to pointer-hand when `ListTile` is returned in `itemBuilder`
- Add to other list, Typeahead suggestion box auto focus HOT 1
- [Bug] - Clear Suggestions Cache
- Navigating back to a typeaheadfield with a swipe gesture makes the field lose focus and become unresponsive HOT 1
- [Bug] Drop frame in 5.x.x version HOT 1
- [Bug] Magnifier doesn't show the text on iOS
- Green Screen Flicker Behind Keyboard
- suggestionCallback does not get called when the builder property returns a textfield HOT 2
- [Bug] TextInputAction.next doesn't work properly
- [Bug] TextField Does Not Call Suggestions Callback On Flutter Web Only
- [Bug] Floater is built too early, casuing "Cannot hit test a render box" when in an eagerly loaded PageView HOT 1
- [Bug] iOS only BackdropFilter with ImageFilter blur is not applied to TypeAheadField
- Support for android [Feature] HOT 1
- [Bug] Project won't build on latest version of Flutter 3.24.0 (due to pointer interceptor issue) HOT 1
- [Bug] OnSelected function not working in version:5.2.0
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flutter_typeahead.