You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Proposal] Allow possibility to maintain focus on TextField #92541
Allow the possibility to maintain focus on a TextField.
It should be disabled by default according to the material design specification but can be enabled through a property.
Note:
If this is already possible, kindly point me to the documentation or a working example.
Thank you
changed the title [-]Is there a possibility that we can choose whether or not we want to keep the focus on TextField?[/-][+][Proposal] Allow possibility to maintain focus on TextField[/+]on Oct 27, 2021
@HansMuller@darshankawar
I found that the TextField widget can keep its focus status now. Has this proposal been passed? If so, can you tell me which parameter can control this status?
@HansMuller Do you mean the cursor height regression?
I found that the TextField widget can keep its focus status now.
Unless I missed something that has changed, this is probably a regression: the focus should be removed from the text field when clicking outside of it. @justinmc has anything changed with FocusTrap?
This is a valid issue (kind of overlapping with #86972, but I think it's ok to keep this open). Here's the current situation.
Desired behavior
On web, tapping on a blank area outside of a text field should remove the focus. Tabbing from there should resume the tab order at the beginning.
On all non-web platforms, tapping on a blank area should not remove focus.
On all platforms, it should be possible to build a button that does not steal the focus from a text field when tapped.
Current Flutter behavior
On all platforms except mobile, tapping on a blank area removes focus from a text field.
This includes mobile web, incorrectly.
It's not possible to build a button that doesn't steal focus due to how FocusTrap works.
How can we fix this?
We need to refactor FocusTrap. I made an attempt at that (#99434), but I ran into test failures due to overlapping gesture detectors, and I haven't been able to figure out a way to fix it. I hope to come back to it, but if anyone else has a solution it would be most welcome!
I've put up a small partial fix (just the platform behavior): #99849. It will still not be possible to build a button that doesn't steal focus on web, unfortunately.
That would basically mean it is impossible to build the following behavior in Flutter, i.e. the keyboard staying open when tapping to record a voice message (e.g. Instagram):
RPReplay_Final1650899053.mov
At least from what I tried, I could not make it work. In whatever way I setup the widgets, the keyboard always closes when tapping the record button.
This should now be possible using the TextFieldTapRegion widget to indicate that a control is considered part of the same tap region group as the text field. See the PR: #107262
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 flutter doctor -v and a minimal reproduction of the issue.
Activity
[-]Is there a possibility that we can choose whether or not we want to keep the focus on TextField?[/-][+][Proposal] Allow possibility to maintain focus on TextField[/+]HansMuller commentedon Oct 27, 2021
CC @gspencergoog
YowFung commentedon Mar 9, 2022
@HansMuller @darshankawar
I found that the
TextFieldwidget can keep its focus status now. Has this proposal been passed? If so, can you tell me which parameter can control this status?HansMuller commentedon Mar 9, 2022
@justinmc, @gspencergoog - was the regression reported in #92079 fixed?
gspencergoog commentedon Mar 9, 2022
@HansMuller Do you mean the cursor height regression?
Unless I missed something that has changed, this is probably a regression: the focus should be removed from the text field when clicking outside of it. @justinmc has anything changed with
FocusTrap?justinmc commentedon Mar 9, 2022
This is a valid issue (kind of overlapping with #86972, but I think it's ok to keep this open). Here's the current situation.
Desired behavior
Current Flutter behavior
How can we fix this?
We need to refactor FocusTrap. I made an attempt at that (#99434), but I ran into test failures due to overlapping gesture detectors, and I haven't been able to figure out a way to fix it. I hope to come back to it, but if anyone else has a solution it would be most welcome!
justinmc commentedon Mar 9, 2022
I've put up a small partial fix (just the platform behavior): #99849. It will still not be possible to build a button that doesn't steal focus on web, unfortunately.
YowFung commentedon Mar 10, 2022
My current situation:
2.10.3 stable.macOSplatform.TextField.My desired behavior:
TextFieldhas a parameter that can control the focus behavior(keep or remove focus when clicking outside of it).creativecreatorormaybenot commentedon Apr 25, 2022
This applies to all platforms, right? @justinmc
That would basically mean it is impossible to build the following behavior in Flutter, i.e. the keyboard staying open when tapping to record a voice message (e.g. Instagram):
RPReplay_Final1650899053.mov
At least from what I tried, I could not make it work. In whatever way I setup the widgets, the keyboard always closes when tapping the record button.
gspencergoog commentedon Aug 1, 2022
This should now be possible using the
TextFieldTapRegionwidget to indicate that a control is considered part of the same tap region group as the text field. See the PR: #107262github-actions commentedon Aug 16, 2022
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
flutter doctor -vand a minimal reproduction of the issue.