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

refactor(tab): remove tabIndex set and unset for jsdom #379

Merged
merged 1 commit into from Jun 22, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 0 additions & 9 deletions src/tab.js
Expand Up @@ -103,16 +103,7 @@ function tab({shift = false, focusTrap} = {}) {
!continueToTab && previousElement ? previousElement : nextElement

if (continueToTab) {
const hasTabIndex = nextElement.getAttribute('tabindex') !== null
if (!hasTabIndex) {
nextElement.setAttribute('tabindex', '0') // jsdom requires tabIndex=0 for an item to become 'document.activeElement'
}

focus(nextElement)

if (!hasTabIndex) {
nextElement.removeAttribute('tabindex') // leave no trace. :)
}
}

fireEvent.keyUp(keyUpTarget, {...tabKeyInit})
Expand Down