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

TreeView: Ignore cmd/alt+arrow key events #3413

Merged
merged 2 commits into from
Jun 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/polite-kings-rhyme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@primer/react": patch
---

TreeView: Ignore arrow key events when combined with cmd or alt keys to avoid interfering with native browser shortcuts.
4 changes: 4 additions & 0 deletions src/TreeView/TreeView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -397,11 +397,15 @@ const Item = React.forwardRef<HTMLElement, TreeViewItemProps>(
}
break
case 'ArrowRight':
// Ignore if modifier keys are pressed
if (event.altKey || event.metaKey) return
event.preventDefault()
event.stopPropagation()
setIsExpandedWithCache(true)
break
case 'ArrowLeft':
// Ignore if modifier keys are pressed
if (event.altKey || event.metaKey) return
event.preventDefault()
event.stopPropagation()
setIsExpandedWithCache(false)
Expand Down