Skip to content

Commit

Permalink
Replace ternary operators
Browse files Browse the repository at this point in the history
  • Loading branch information
echo-vladimir committed Nov 5, 2024
1 parent 3651999 commit e39c91c
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions focus-group.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,20 +92,22 @@ export function focusGroupKeyUX(options) {
if (event.key === nextKey) {
event.preventDefault()
if (group.hasAttribute('focusgroup')) {
items[index + 1]
? focus(event.target, items[index + 1])
: group.getAttribute('focusgroup').includes('wrap') &&
focus(event.target, items[0])
if (items[index + 1]) {
focus(event.target, items[index + 1])
} else if (group.getAttribute('focusgroup').includes('wrap')) {
focus(event.target, items[0])
}
} else {
focus(event.target, items[index + 1] || items[0])
}
} else if (event.key === prevKey) {
event.preventDefault()
if (group.hasAttribute('focusgroup')) {
items[index - 1]
? focus(event.target, items[index - 1])
: group.getAttribute('focusgroup').includes('wrap') &&
focus(event.target, items[items.length - 1])
if (items[index - 1]) {
focus(event.target, items[index - 1])
} else if (group.getAttribute('focusgroup').includes('wrap')) {
focus(event.target, items[items.length - 1])
}
} else {
focus(event.target, items[index - 1] || items[items.length - 1])
}
Expand Down

0 comments on commit e39c91c

Please sign in to comment.