-
Notifications
You must be signed in to change notification settings - Fork 28.7k
Replace FocusTrap with TapRegionSurface #107262
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
1711e0d
to
24af3c5
Compare
In looking at the test failures, it's clear that we'd have to figure something out for the cut/copy/paste toolbar so that clicking on it doesn't cause the field to be unfocused. |
4b0c965
to
f4d43b5
Compare
d51ce96
to
68a421d
Compare
OK, after a few false starts, this is pretty much exactly what @venkatd had, with the addition of groups. I've also integrated groups into the selection dialogs so that taps on the overlay dialogs don't unfocus the text field. |
53224d4
to
632edbe
Compare
There's still some documentation that needs to be written for this, but does this seem like a reasonable replacement for |
And probably some name refinement. I went with |
And it needs more tests too. Switching back to Draft PR for now. |
This pull request has been changed to a draft. The currently pending flutter-gold status will not be able to resolve until a new commit is pushed or the change is marked ready for review again. For more guidance, visit Writing a golden file test for Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
5a7a04a
to
c83e8d4
Compare
26c9de7
to
85eb293
Compare
Hi @Eerey
To be clear: you're talking about the case of building your own virtual keyboard, right? Not a system built-in keyboard? You should be able to do that, but you might need to wrap the web view in a With this change, building a virtual keyboard should be a lot easier, however. |
Good evening @gspencergoog
Yes, correct.
That sounds amazing. I am very much looking forward to it. |
This reverts commit f5e4d2b because it causes Google test failures.
Hi, where can we observe if this feature is currently present? When will this be available in the master channel? :) currently running flutter 3.3.4 |
@Eerey It is currently present in the master and beta channels. It will be in stable with the next stable release. Just for future reference, the master channel is the first place where things are added, so something new is always available in the master channel. There is only a delay for things going into the more stable channels (beta and stable). See https://github.com/flutter/flutter/wiki/Flutter-build-release-channels for more information. |
@gspencergoog Should this not have gone through the breaking change policy by including a design doc and migration guide for |
@Jjagg I'm sorry it was hard to find. Hopefully the migration wasn't too hard, and that it meets your needs better than |
@gspencergoog It wasn't too bad and this is a way more flexible solution, so I'm very happy with this change :) Ah sorry, I thought public API changes fell under the policy. I'll have to remember to submit some stuff to the contributed tests sometimes. |
A PR to address #86972
The code derives largely from the suggestion in this comment, as well as some explorations I had while working on the
MenuBar
widget. It differs from Venkat's code in that there is also a grouping mechanism for the regions, so that multiple regions can act as one, allowing things like taps on the text field toolbars to not unfocus the text field.The way
TapRegionSurface
is supposed to work is that it wraps the whole app area, and triggers anyonTapOutside
callbacks for regions or groups of regions when a tap occurs.This is a shift from how
FocusTrap
works, in that widgets that want to have the focus disappear will need to do some setup instead of getting it by default. SinceTextField
is the main widget that wants to do this, that shouldn't really be too hard. I added anonTapOutside
andtapRegionGroupId
attributes toTextField
that if unset, will do whatFocusTrap
used to do (only lose focus on desktop and web platforms). But you can also set it if you want to override that behavior, or disable it, and place theTextField
inside of aTapRegion
group that includes, for instance, value spinners or a "copy to clipboard" button so that they won't affect the focus.Usage looks something like this:
cc @justinmc @venkatd @jpnurmi