Skip to content

Commit

Permalink
fix: only prevent tab if next tabbable is found
Browse files Browse the repository at this point in the history
  • Loading branch information
visualjerk committed Aug 9, 2020
1 parent 1140299 commit e68998e
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/Dialog/Dialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,11 @@ function handleTab(
)
const tabbableElements = getTabbableElements(ref.value)
if (!event.shiftKey && reachedLastTabbable(tabbableElements)) {
getNextTabbable(disclosure)?.focus()
event.preventDefault()
const nextTabbable = getNextTabbable(disclosure)
if (nextTabbable) {
nextTabbable.focus()
event.preventDefault()
}
} else if (event.shiftKey && reachedFirstTabbable(tabbableElements)) {
disclosure.focus()
event.preventDefault()
Expand Down

0 comments on commit e68998e

Please sign in to comment.