Skip to content

Commit

Permalink
Merge pull request #3578 from udecode/fix/onKeyDownSelection
Browse files Browse the repository at this point in the history
Fix/on key down selection
  • Loading branch information
felixfeng33 authored Sep 24, 2024
2 parents f266434 + 7483acc commit ac4e1b5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/fifty-walls-trade.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@udecode/plate-selection': patch
---

If `defaultPrevented` is true stop keydown handlers.
4 changes: 4 additions & 0 deletions packages/selection/src/react/onKeyDownSelection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ export const onKeyDownSelection: KeyboardHandler<BlockSelectionConfig> = ({
event,
}) => {
if (isHotkey('mod+a', event)) {
if (event.defaultPrevented) return;

const ancestorNode = getAncestorNode(editor);

if (!ancestorNode) return;
Expand All @@ -36,6 +38,8 @@ export const onKeyDownSelection: KeyboardHandler<BlockSelectionConfig> = ({
event.stopPropagation();
}
if (isHotkey('escape', event)) {
if (event.defaultPrevented) return;

const ancestorNode = getAncestorNode(editor);
const id = ancestorNode?.[0].id;

Expand Down

0 comments on commit ac4e1b5

Please sign in to comment.