Skip to content

Commit

Permalink
fix: fix android backspace bug (#5077)
Browse files Browse the repository at this point in the history
  • Loading branch information
cristopher-iov authored Oct 13, 2023
1 parent 619917b commit ca45b1d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/lexical/src/LexicalEvents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import type {TextNode} from './nodes/LexicalTextNode';

import {
CAN_USE_BEFORE_INPUT,
IS_ANDROID,
IS_APPLE_WEBKIT,
IS_FIREFOX,
IS_IOS,
Expand Down Expand Up @@ -515,6 +516,10 @@ function onBeforeInput(event: InputEvent, editor: LexicalEditor): void {

if ($isRangeSelection(selection)) {
// Used for handling backspace in Android.
if (IS_ANDROID) {
$setCompositionKey(selection.anchor.key);
}

if (
isPossiblyAndroidKeyPress(event.timeStamp) &&
editor.isComposing() &&
Expand Down
3 changes: 3 additions & 0 deletions packages/shared/src/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ export const IS_IOS: boolean =
/iPad|iPhone|iPod/.test(navigator.userAgent) &&
!window.MSStream;

export const IS_ANDROID: boolean =
CAN_USE_DOM && /Android/.test(navigator.userAgent);

// Keep these in case we need to use them in the future.
// export const IS_WINDOWS: boolean = CAN_USE_DOM && /Win/.test(navigator.platform);
export const IS_CHROME: boolean =
Expand Down

2 comments on commit ca45b1d

@vercel
Copy link

@vercel vercel bot commented on ca45b1d Oct 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

lexical – ./packages/lexical-website

lexical-git-main-fbopensource.vercel.app
lexicaljs.org
lexical-fbopensource.vercel.app
lexical.dev
lexicaljs.com
www.lexical.dev

@vercel
Copy link

@vercel vercel bot commented on ca45b1d Oct 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

lexical-playground – ./packages/lexical-playground

lexical-playground.vercel.app
lexical-playground-git-main-fbopensource.vercel.app
lexical-playground-fbopensource.vercel.app
playground.lexical.dev

Please sign in to comment.