Remove options when ending focus management #399
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.
Context
What are you trying to accomplish?
Fix bug found when removing nodes in a focus zone and with strict mode enabled. Also, I added a test to check for this.
What approach did you choose and why?
We were running into focus inconsistencies when using
useFocusZone
in our component. I pinpointed it to this linewhere an empty array was being returned from
and the
endFocusManagement
is unable to remove the focusable elements causing jumpy focus behavior for the user.This was because in our component, we passed
strict=true
in theiterateFocusableElementsOptions
object, which hits these lines of strict checks insideiterateFocusableElements
. Because the node no longer existed/was removed, thestrict
check failed and returned an empty array.I removed the
iterateFocusableElementsOptions
argument so when a node is removed all focusable elements within it are removed from thefocusableElements
list