-
Notifications
You must be signed in to change notification settings - Fork 29k
Fix ExcludeFocus
so it won't refocus a sibling of the focused node.
#61756
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
88e40d3
to
4eb0037
Compare
ExcludeFocus
so it won't refocus a sibling of the focused node.
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.
LGTM.
@@ -864,19 +867,19 @@ class FocusNode with DiagnosticableTreeMixin, ChangeNotifier { | |||
while (!scope.canRequestFocus) { | |||
scope = scope.enclosingScope ?? _manager?.rootScope; | |||
} | |||
scope?._doRequestFocus(findFirstFocus: false); | |||
scope._doRequestFocus(findFirstFocus: false); |
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.
Are these changes here related to the fix, or just cleaning up something? I assume scope can no longer be null when it might have before?
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.
Actually, I made those changes thinking that these couldn't ever be null, because the rootScope
can't be null, but if the _manager
is null, it still could be. I reverted these.
4eb0037
to
d632495
Compare
…flutter#61756) This changes FocusNode.descendantsAreFocusable so that it doesn't allow the enclosing scope to re-focus a node that is a descendant of the node with descendantsAreFocusable set to false. Because of the order in which the internal state for descendantsAreFocusable was being set, setting it to false was causing a sibling node to be focused when descendantsAreFocusable of the parent was set to false, even though it shouldn't have been focusable, because the enclosing scope would search for a candidate to be focused before the internal state was set to false. Instead of looping over the children and telling them all to unfocus (and select the previously focused node), this unfocuses the node that has descendantsAreFocusable set to false, with the disposition UnfocusDisposition.previouslyFocusedChild, so that its enclosing scope will look for a previously focused child that isn't part of the subtree being excluded. This affects how the ExcludeFocus widget behaves when turning on exclude.
…flutter#61756) This changes FocusNode.descendantsAreFocusable so that it doesn't allow the enclosing scope to re-focus a node that is a descendant of the node with descendantsAreFocusable set to false. Because of the order in which the internal state for descendantsAreFocusable was being set, setting it to false was causing a sibling node to be focused when descendantsAreFocusable of the parent was set to false, even though it shouldn't have been focusable, because the enclosing scope would search for a candidate to be focused before the internal state was set to false. Instead of looping over the children and telling them all to unfocus (and select the previously focused node), this unfocuses the node that has descendantsAreFocusable set to false, with the disposition UnfocusDisposition.previouslyFocusedChild, so that its enclosing scope will look for a previously focused child that isn't part of the subtree being excluded. This affects how the ExcludeFocus widget behaves when turning on exclude.
Description
This changes
FocusNode.descendantsAreFocusable
so that it doesn't allow the enclosing scope to re-focus a node that is a descendant of the node withdescendantsAreFocusable
set to false.Because of the order in which the internal state for
descendantsAreFocusable
was being set, setting it to false was causing a sibling node to be focused whendescendantsAreFocusable
of the parent was set to false, even though it shouldn't have been focusable, because the enclosing scope would search for a candidate to be focused before the internal state was set to false.Instead of looping over the children and telling them all to unfocus (and select the previously focused node), this unfocuses the node that has
descendantsAreFocusable
set to false, with the dispositionUnfocusDisposition.previouslyFocusedChild
, so that its enclosing scope will look for a previously focused child that isn't part of the subtree being excluded.This affects how the
ExcludeFocus
widget behaves when turning onexclude
.Related Issues
Tests
Breaking Change