-
Notifications
You must be signed in to change notification settings - Fork 27.2k
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
DropdownButtonFormField immediately reset when clicking on if if a Textfield has the focus #42646
Comments
Probably related to #40333 |
OK. together with the help of @slightfoot we found the source of the problem is that By adding a manual Focus we could solve it like this: Focus(
focusNode: _node,
onFocusChange: (bool focus) {
setState((){});
},
child: Listener(
onPointerDown: (_) {
FocusScope.of(context).requestFocus(_node);
},
child: DropdownButtonFormField(
iconSize: 50,
style: TextStyle(color: _node.hasFocus ? Colors.white : Colors.white70, fontSize: 24),
onChanged: (s) {},
hint: Text('Select a Map',
style: TextStyle(color: _node.hasFocus ? Colors.white : Colors.white70),
),
items: [
DropdownMenuItem(value: '1', child: Text('Map 1')),
DropdownMenuItem(value: '2', child: Text('Map 2')),
DropdownMenuItem(value: '3', child: Text('Map 3')),
],
),
),
) This should be fixed by adding a FocusNode to |
I also tried it with the current stable, where it kind of worked but had other strange effects |
Yes seems to be the same effect although I think Simon analysis that the problem is the missing focusnode of DropDownButtons is the correct one. Because adding a focus fixed it. |
I think it also needs a focus node, which might help with accessibility focus as well, since dropdown buttons aren't often focused implicitly by TalkBack. I'll look at adding one, regardless of whether #42482 fixes it. |
I tested this with the above PR, and it fixes the problem. |
… for it. (#42811) This adds a Focus node to the DropdownButton widget, allowing it to receive keyboard focus, and to show a focus highlight. In addition, I added the ability to activate the dropdown using the "enter" key binding (which is bound to ActivateAction in the WidgetsApp). Related Issues Fixes #42646 Fixes #43008 Fixes #42511
… for it. (flutter#42811) This adds a Focus node to the DropdownButton widget, allowing it to receive keyboard focus, and to show a focus highlight. In addition, I added the ability to activate the dropdown using the "enter" key binding (which is bound to ActivateAction in the WidgetsApp). Related Issues Fixes flutter#42646 Fixes flutter#43008 Fixes flutter#42511
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of |
Please see here:
Steps to Reproduce
Run this App:
Click in one of the Text fields and try to open the DopDownButton
Target Platform: Android
Target OS version/browser: API 28
Devices: Emulator
Logs
The text was updated successfully, but these errors were encountered: