-
Notifications
You must be signed in to change notification settings - Fork 29k
Added proper focus handling when pushing and popping routes #40166
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
Codecov Report
@@ Coverage Diff @@
## master #40166 +/- ##
==========================================
- Coverage 60.07% 58.11% -1.96%
==========================================
Files 193 192 -1
Lines 18751 18443 -308
==========================================
- Hits 11265 10719 -546
- Misses 7486 7724 +238
Continue to review full report at Codecov.
|
7e3d396
to
27988c4
Compare
8f65927
to
1f31744
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't say that I understand all of the implications of this (sensible) change. LGTM though.
1f31744
to
f240aff
Compare
f240aff
to
c1d2a20
Compare
c1d2a20
to
8f8368f
Compare
…40166) The proposed change will change focus handling when pushing and popping routes so that the FocusScopeNode for the route receives focus when pushed, and that the FocusScopeNode in the navigator receives focus when the route is popped. This means that the last setFirstFocus call on the scope is used to determine which control actually receives focus. When the focus scope receives focus, it traverses its children, trying to find a non-scope node that is the "first focus" of itself or a child node. This is a breaking change, because the focus behavior has changed. If you push a route after this change, and had a 'first focus' set on a widget via FocusScopeNode.setFirstFocus, it won't currently receive focus immediately, but after this change it will. Similarly, if you pop a route after this change, the focus will go back to where it was before the route was pushed, which is correct, but different from what happens now.
@gspencergoog This causes an issue when the route that's pushed is not a modal route, like a dropdown button or a popupmenu. It goes against the standard android behavior. |
@ThinkDigitalSoftware Can you elaborate? This change should only change focus when pushing a route if |
Well in my case, I haven't set any of those properties. I have a barebones example where when you tap a textfield and then a Dropdown, once the Dropdown is dismissed, the textfield is activated again and the keyboard always comes up, whether it was up previously or not. It makes sense for modal routes, because you're returning to where you are. But if you're filling out a form, this causes the screen to scroll back to the textfield and activate it, regardless of how far it is from the Dropdown /popup |
This pr was meant to address some of the issues, but not all. Also, I'm not sure if your PR caused all of the issues I'm having. I probably shouldn't insinuate that, but someone linked here and mentioned that this is when the behavior changed. #41574 |
@ThinkDigitalSoftware, I see the issue. I've also seen something else that is related just now, so I'm filing a bug and will look at it tomorrow: #41881 |
Description
The proposed change will change focus handling when pushing and popping routes so that the
FocusScopeNode
for the route receives focus when pushed, and that theFocusScopeNode
in the navigator receives focus when the route is popped.This means that the last
setFirstFocus
call on the scope is used to determine which control actually receives focus. When the focus scope receives focus, it traverses its children, trying to find a non-scope node that is the "first focus" of itself or a child node.This is a breaking change, because the focus behavior has changed. If you push a route after this change, and had a 'first focus' set on a widget via
FocusScopeNode.setFirstFocus
, it won't currently receive focus immediately, but after this change it will. Similarly, if you pop a route after this change, the focus will go back to where it was before the route was pushed, which is correct, but different from what happens now.Related Issues
Addresses #13264
Tests
Checklist
Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes (
[x]
). This will ensure a smooth and quick review process.///
).flutter analyze --flutter-repo
) does not report any problems on my PR.Breaking Change
Does your PR require Flutter developers to manually update their apps to accommodate your change?