Skip to content
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

Ensure correct DOM node order when performing focus actions #1038

Merged
merged 4 commits into from
Jan 14, 2022

Commits on Jan 14, 2022

  1. ensure that the order of DOM nodes is correct

    When we are performing actions like `focusIn(list, Focus.First)` then we
    have to ensrue that we are working with the correct list that is
    properly sorted.
    
    It can happen that the list of DOM nodes is out of sync. This can happen
    if you have 3 Tabs, hide the second (which triggers an unmount and an
    `unregister` of the Tab), then re-add the second item in the middle.
    This will re-add the item to the end of the list instead of in the middle.
    
    We can solve this by always sorting items when we are adding / removing
    items, but this is a bit more error prone because it is easy to forget.
    Instead we will sort it when performing the actual keyboard action.
    
    If we didn't provide a list but an element, then we use a
    getFocusableElements(element) function, but this already gives you a
    correctly sorted list so we don't need to do that for this list.
    RobinMalfait committed Jan 14, 2022
    Configuration menu
    Copy the full SHA
    ec0c9bf View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    e27990c View commit details
    Browse the repository at this point in the history
  3. cleanup code just for tests

    It could still happen that this internal list is not ordered correctly
    but that's not really a problem we just have the list to keep track of
    things.
    
    For our tests we now use the position from the DOM directly.
    RobinMalfait committed Jan 14, 2022
    Configuration menu
    Copy the full SHA
    d26f7bf View commit details
    Browse the repository at this point in the history
  4. update changelog

    RobinMalfait committed Jan 14, 2022
    Configuration menu
    Copy the full SHA
    f1b6113 View commit details
    Browse the repository at this point in the history