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

Fix the cursor moves one space backward when inserting text after an emoji #42985

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,9 @@ function ComposerWithSuggestions(
*/
const updateComment = useCallback(
(commentValue: string, shouldDebounceSaveComment?: boolean) => {
if (isIOSNative) {
syncSelectionWithOnChangeTextRef.current = null;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

if (isIOSNative) {
syncSelectionWithOnChangeTextRef.current = {position, value: newComment};
}

I think your main solution to add additional here should work, right?

if (commentWithSpaceInserted !== newComment && isIOSNative) {

Copy link
Contributor Author

@bernhardoj bernhardoj Jun 4, 2024

Choose a reason for hiding this comment

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

My main solution is actually to use it here, but this breaks on other platforms.

That works too though. Which one do you prefer?

Copy link
Contributor

@eh2077 eh2077 Jun 4, 2024

Choose a reason for hiding this comment

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

I think adding additional check here is better

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated!

Copy link
Contributor

Choose a reason for hiding this comment

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

Or should we remove

if (isIOSNative) {
syncSelectionWithOnChangeTextRef.current = {position, value: newComment};
}
if you set it to null above

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If we remove it, #29405 will happen again.

raiseIsScrollLikelyLayoutTriggered();
const {startIndex, endIndex, diff} = findNewlyAddedChars(lastTextRef.current, commentValue);
const isEmojiInserted = diff.length && endIndex > startIndex && diff.trim() === diff && EmojiUtils.containsOnlyEmojis(diff);
Expand Down
Loading