Skip to content

Commit

Permalink
bug: RovingFocus now respects alt-keys
Browse files Browse the repository at this point in the history
  • Loading branch information
KenAJoh committed Jul 4, 2024
1 parent 420c5c3 commit ce7004b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
9 changes: 8 additions & 1 deletion @navikt/core/react/src/tabs/parts/tablist/useTabList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,16 @@ export function useTabList() {
End: lastTab,
};

const shouldDoAction = !(
event.shiftKey ||
event.ctrlKey ||
event.altKey ||
event.metaKey
);

const action = keyMap[event.key];

if (action) {
if (shouldDoAction && action) {
event.preventDefault();
action(event);
} else if (event.key === "Tab") {
Expand Down
9 changes: 8 additions & 1 deletion @navikt/core/react/src/toggle-group/parts/useToggleItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,16 @@ export function useToggleItem<P extends UseToggleItemProps>(
End: lastTab,
};

const shouldDoAction = !(
event.shiftKey ||
event.ctrlKey ||
event.altKey ||
event.metaKey
);

const action = keyMap[event.key];

if (action) {
if (shouldDoAction && action) {
event.preventDefault();
action(event);
} else if (event.key === "Tab") {
Expand Down

0 comments on commit ce7004b

Please sign in to comment.