• Greg Spencer's avatar
    Fix `ExcludeFocus` so it won't refocus a sibling of the focused node. (#61756) · cac22cdb
    Greg Spencer authored
    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.
    cac22cdb
focus_scope_test.dart 57 KB