Skip to content

Commit

Permalink
fix: propagate Escape out of dialog
Browse files Browse the repository at this point in the history
Previously, the Escape key was swallowed and in turn, if the picker was
displayed in a dialog, the dialog would not close.

Relates to PS-21279.
  • Loading branch information
daelmaak committed Jul 2, 2024
1 parent 6417fbb commit 17e15b8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
5 changes: 4 additions & 1 deletion packages/emoji-mart/src/components/Navigation/Navigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ export default class Navigation extends PureComponent {
}

handleKeyDown = (e: KeyboardEvent) => {
e.stopImmediatePropagation()
// Escape should still propagate up since it can be used in a dialog
if (e.key !== 'Escape') {
e.stopImmediatePropagation()
}

switch (e.key) {
case 'ArrowLeft':
Expand Down
8 changes: 6 additions & 2 deletions packages/emoji-mart/src/components/Picker/Picker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -406,10 +406,14 @@ export default class Picker extends Component {
this.setState({ searchResults: grid, pos }, afterRender)
}

handleEmojisKeyDown = (e) => {
handleEmojisKeyDown = (e: KeyboardEvent) => {
// const specialKey = e.altKey || e.ctrlKey || e.metaKey
const input = this.refs.searchInput.current
e.stopImmediatePropagation()

// Escape should still propagate up since it can be used in a dialog
if (e.key !== 'Escape') {
e.stopImmediatePropagation()
}

switch (e.key) {
case 'ArrowLeft':
Expand Down

0 comments on commit 17e15b8

Please sign in to comment.