Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Text format lost after auto-correcting on iOS #4801

Open
samirant15 opened this issue Jul 18, 2023 · 4 comments · May be fixed by #5397 or #5789
Open

Bug: Text format lost after auto-correcting on iOS #4801

samirant15 opened this issue Jul 18, 2023 · 4 comments · May be fixed by #5397 or #5789
Labels
composition Relating to IME inputs ios-bug

Comments

@samirant15
Copy link

On an IOS device, if the user typed a misspelled word with formats like Bold or Italic, after clicking the autocorrected work on the native keyboard, it replaces the word with the correct one but the formats are lost.

Example from lexical playground website and an IOS simulator (note: it also happens on physical devices)
autocorrect-lexical

Lexical version: 0.11.2

Steps To Reproduce

  1. On a lexical editor type a word with formatting applied
  2. Make sure it is a misspelled word so the native keyboard prompts you to correct it
  3. Tap on the native keyboard suggestion and the word will be corrected but the formats are lost

Link to code example: It happens in the playground https://github.com/facebook/lexical/tree/main/packages/lexical-playground (see above screen record)

The current behavior

After autocorrecting a word on IOS the text formats are lost

The expected behavior

After autocorrecting a word on IOS the text formats should be kept

@acywatson acywatson added ios-bug composition Relating to IME inputs labels Jul 21, 2023
@cakj
Copy link

cakj commented Nov 15, 2023

Hi,
it's not only for iOS devices, you can reproduce this issue on a Mac with safari as well.

@laulautrup
Copy link

Yes we also experience this issue on iOS version 0.12.2. Did anyone find a fix yet?

@amanharwara
Copy link
Contributor

@acywatson I don't think this is an issue with composition. From what I can tell, the trace looks something like this:
onBeforeInput -> insertReplacementText -> CONTROLLED_TEXT_INSERTION_COMMAND -> $insertDataTransferForRichText -> $insertGeneratedNodes -> RangeSelection.insertNodes -> removeTextAndSplitBlock

Maybe the inserted nodes should be given the format of the current selection? 🤔

@amanharwara
Copy link
Contributor

amanharwara commented Dec 16, 2023

This issue also doesn't happen if we ignore the text/html string in the $insertDataTransferForRichText and only use the text/plain content.

So one possible fix might be to have the event be one of the parameters for the insertDataTransfer function, and if the event.input.type === "insertReplacementText" then ignore the text/html data.

Created a PR with this approach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
composition Relating to IME inputs ios-bug
Projects
None yet
5 participants