• Greg Spencer's avatar
    Fix route focusing and autofocus when reparenting focus nodes. (#42554) · e2c5fd6c
    Greg Spencer authored
    This fixes a problem with reparenting of focus nodes where it would remove the node from the scope's focused children when reparented, even if it was being reparented to another place under the same scope. This only occurred if the scope in question didn't have focus.
    
    This caused nodes to not get autofocused when they were a child of another node within the scope, and were reparented, and then the scope was given focus (as when a route is pushed).
    
    This keeps the node in the scope's child list where it was if the node is reparented under a parent within the same scope.
    
    - Added a test that tries to autofocus a TextField when the route is pushed and there is another 
      FocusNode above the text field. This was how this was first noticed: the autofocus got ignored in 
      this configuration.
    
    - Added a test to focus_manager_test that tests for the specific case of reparenting a node when 
      it's in the focused children of the scope.
    e2c5fd6c
routes_test.dart 15 KB