Skip to content

Commit

Permalink
Fix shouldLetBrowserHandleDelete
Browse files Browse the repository at this point in the history
  • Loading branch information
waynetee committed Feb 3, 2025
1 parent 07beda8 commit a90b93a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/lexical/src/LexicalEvents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -606,15 +606,17 @@ function onBeforeInput(event: InputEvent, editor: LexicalEditor): void {
const hasSelectedAllTextInNode =
selection.anchor.offset === 0 &&
selection.focus.offset === selectedNodeText.length;
const shouldLetBrowserHandleDelete =
let shouldLetBrowserHandleDelete =
IS_ANDROID_CHROME &&
isSelectionAnchorSameAsFocus &&
!hasSelectedAllTextInNode &&
selectedNodeCanInsertTextAfter;
// Check if selection is collapsed and if the previous node is a decorator node
// If so, the browser will not be able to handle the deletion
if (shouldLetBrowserHandleDelete && selection.isCollapsed()) {
shouldLetBrowserHandleDelete = !$isDecoratorNode($getAdjacentNode(selection.anchor, true));
shouldLetBrowserHandleDelete = !$isDecoratorNode(
$getAdjacentNode(selection.anchor, true),
);
}
if (!shouldLetBrowserHandleDelete) {
dispatchCommand(editor, DELETE_CHARACTER_COMMAND, true);
Expand Down

0 comments on commit a90b93a

Please sign in to comment.