fix: allow tabbing out of [tabindex=-1] elements #24
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
Currently the plugin will error if you focus a focusable,
tabindex=-1element and try to tab out of it. This is incorrect as long as the element is capable of being focused programmatically, which -1 is.Solutions:
@bkucera suggested moving from ally.js to tabbable.js but ally.js does include a differentiation query between focusable and tabbable. The changes here allow tabbing out of focusable elements (but will still error if trying to tab from non-focusable elements).
WIP:
Focusing on a -1 element and pressing tab currently goes backwards. I believe this has to do with how the index traversal was setup based on isTabbable and needs to be updated to work based on the next item in the isTabbable tree based on the current isFocusable item.
I'll keep trying things but JS isn't my top language by any means so I definitely welcome help from anyone.
This PR includes a separate HTML in fixtures with a simplified setup, as well a series of rudimentary tests on the fixture. Note that it also adds a skip to the plugins original spec files to speed up the testing flow for this issue and it should be reverted prior to merging (potentially in addition to removing the new HTML/spec files).