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

Fix data-focus for nested containers #38

Merged
merged 1 commit into from
Jan 22, 2024

Conversation

Murreey
Copy link
Contributor

@Murreey Murreey commented Jan 22, 2024

Description

Updating the logic for where data-focus gets set

  • Always save the element we're leaving's ID on its parent container
  • Always save the new best candidate's ID on the new candidate container
  • (If these are the same container, the best candidate overwrites it)
  • Store any existing data-focus before doing that, as we still need to use the old value if it existed, not necessarily always the bestCandidate. Then update it if we did have to use it.

Motivation and Context

Last change (#37) was intended to save the data-focus value on every internal move rather than only when leaving a container, so that if focus was moved away for any reason then the data-focus would still be preserved.

That change missed the case of nested containers, so it would store the ID of the inner element on the outer container, not it's actual parent container. Container data-focus should only ever be the ID of a child that belongs to a container.

It also missed that when moving in to a nested container, it should save the data-focus - rather than only when moving between the children of the container. New implementation always makes sure to save the ID moved from and the ID moved to, on every move.

How Has This Been Tested?

New integration test

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@Murreey Murreey requested a review from a team as a code owner January 22, 2024 15:13
@Murreey Murreey merged commit 596771f into master Jan 22, 2024
1 check passed
@Murreey Murreey deleted the fix-active-child-nested-containers branch January 22, 2024 15:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants