Skip to content

Commit

Permalink
Fix Safari issue
Browse files Browse the repository at this point in the history
  • Loading branch information
ellatrix committed Nov 26, 2024
1 parent a72439c commit a386b39
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,19 @@ export function useEventHandlers( { clientId, isSelected } ) {
const { ownerDocument } = node;
const { defaultView } = ownerDocument;
const selection = defaultView.getSelection();
let { anchorNode, focusNode } = selection;
if ( anchorNode !== anchorNode.ELEMENT_NODE ) {
anchorNode = anchorNode.parentElement;
}
if ( focusNode !== focusNode.ELEMENT_NODE ) {
focusNode = focusNode.parentElement;
}
if (
node !== event.target ||
node.contains( selection.anchorNode ) ||
node.contains( selection.focusNode )
( node.contains( anchorNode ) &&
anchorNode.isContentEditable ) ||
( node.contains( focusNode ) &&
focusNode.isContentEditable )
) {
event.preventDefault();
return;
Expand Down

0 comments on commit a386b39

Please sign in to comment.