question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

leavesForLeafSet.first().get('start') returns an incorrect start position for some emoji characters

See original GitHub issue

In DraftEditorBlock.react.js (L190), certain strings cause leavesForLeafSet.first().get('start') to incorrectly report the start position of the string.

For example, entering any of the emoji digits from 0-7 (0️⃣ - 7️⃣) causes leavesForLeafSet.first().get('start') to incorrectly return the start position as 1, rather than 0. Oddly, entering either 8️⃣ or 9️⃣ works as expected and the start position is correctly returned as 0.

This doesn’t appear to have any negative effect on a basic <Editor />, however it becomes an issue when using the emoji plugin as the decoratedText prop that draft-js passes through to it ends up being an emoji modifier character (⃣).

You can see this in action by trying to enter any of the 0️⃣ - 7️⃣ emoji into the first demo (Simple Emoji Example) on the emoji-plugin docs site. (Related issue in draft-js-plugins repo).

Fixing the inconsistencies with leavesForLeafSet.first().get('start') so that it consistently returns the correct start position of all numeric emoji characters would resolve this issue.

Tested with v0.10.5 of draft-js on MacOS 10.13.1

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:6
  • Comments:7

github_iconTop GitHub Comments

1reaction
riddhi-24commented, Jun 28, 2021

Any update?

0reactions
malavshah9commented, Jun 25, 2021

Any progress here?

Read more comments on GitHub >

github_iconTop Results From Across the Web

[emoji-plugin]: Cannot read property 'unicode' of undefined ...
leavesForLeafSet.first().get('start') returns an incorrect start position for some emoji characters facebook/draft-js#1636.
Read more >
swift cursor position with emojis - Stack Overflow
Your issue is that the NSRange value returned by UITextField selectedTextRange and the offset need to be properly converted to a Swift ...
Read more >
How to get all available emojis in an array in Swift
I want to be able to get an array of all the available emojis in Swift. What I mean by available is all...
Read more >
Unicode: Emoji, accents, and international text
Character encoding. Before we can analyze a text in R, we first need to get its digital representation, a sequence of ones and...
Read more >
Emojis in Javascript | Kevin Scott
First, a quick dive into the inner workings of Unicode, followed by how emoji in ... Character Code— Another name for a code...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found