-
Notifications
You must be signed in to change notification settings - Fork 72
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
Fix pasting in composition mode #599
Conversation
Hi @QichenZhu, thanks for the PR. I don't have much expertise in the web part of Live Markdown so I'll just pass it to someone else from the team who will review your PR shortly. Looks like web E2E test is failing, could you please fix it as well? |
Thanks for your help! I’m open to any suggestions or alternative approaches. Web E2E testing has passed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks good, I've tested it against most of the similar issues we've had like voice recognition, diacritics, GBoard and such - on safari, firefox and chromium 👍🏻
I still need to test it with a Samsung phone though, ideally a physical device, so I'll be doing that tomorrow when I get a hold of a phone with Samsung keyboard.
Changing anything related to composition is tricky, since we've had some regressions related to that in the past, hence the throughout testing 😓
@QichenZhu looks like there are some conflicts, can you resolve them please? @BartoszGrajdek were you able to test on a Samsung keyboard? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Tested on a virtual Samsung device and all looked okay to me.
android-chrome-2025-01-22_16.05.24.mp4
Given this comment, should we ask Applause to test once we get to the App PR? @rlinoz |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could actually create a build file with |
7870627
I've just noticed @BartoszGrajdek's comment after I merged this PR. I think it should be safe to update in E/App. If anything goes wrong, we can use patch-package or just prepare another follow-up PR. |
Details
Issues
In the web example app, pasting doesn’t work after typing with Samsung keyboard.
In Expensify app, pasting works, but the caret position is wrong in the case of issue Expensify/App#40025.
Cause
When pasting, mobile browsers don’t fire the
compositionend
event, so the component handles the pasting event in composition mode,react-native-live-markdown/src/MarkdownTextInput.web.tsx
Lines 373 to 384 in 76258f1
and the normal process doesn’t execute.
react-native-live-markdown/src/MarkdownTextInput.web.tsx
Line 399 in 76258f1
Solution
This PR fixes the issue by detecting composition mode with the
isEventComposing()
function.Related Issues
Expensify/App#40025
PROPOSAL: Expensify/App#40025 (comment)
Manual Tests
Precondition: Use a soft keyboard in composition mode, such as Samsung keyboard with autocorrection enabled.
before.mp4
after.mp4
Linked PRs