Fix data-focus for nested containers #38
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Updating the logic for where
data-focus
gets setMotivation 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: