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.

editor.selection not updating after insertText

See original GitHub issue

Description

Prior to 0.66.0 editor.selection was updating after insertText to account for the next text. However, any text entry after the first does not update the selection and the offset stays at the previous.

Recording I tested on the Link slate example by adding console.log(editor.selection) before and after this line. Below is the console logs after inserting 3 fs Screen Shot 2021-09-22 at 6 26 11 PM

Sandbox I made a simplified sandbox of it showing the console logs of the editor selection https://codesandbox.io/s/slate-reproductions-forked-9ub7c?file=/index.js

Steps To reproduce the behavior:

  1. go to above sandbox
  2. insert text in slate editor
  3. see the console and see that the editor selection stays the same.
  4. change slate versions to 0.65 and repeat
  5. see that editor selection updates

Expectation I expected the editor selection to update after insertText because that it how it used to work before the update.

Environment

  • Slate Version: 0.66
  • Operating System: macOS
  • Browser: Chrome

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
dylanscommented, Sep 28, 2021

@codewitch Thanks. @nemanja-tosic and I have been discussing it and trying to come up with a good solution and we haven’t come up with something easy yet or we would have already fixed it. We should also see if @bkrausz has thoughts.

Mostly we just need time to figure out a good solution that hopefully doesn’t break something else along the way.

0reactions
NicerDicerProcommented, Dec 15, 2022

Hi @dylans, im currently facing the same issue in version 0.86.0.

Are there any updates on this? Should this already be fixed?

Read more comments on GitHub >

github_iconTop Results From Across the Web

setState() will block editor.insertText() before it. #2549 - GitHub
Update : If I add a editor.flush() after insertText(), then when I press 'a', it first show '11a' and then an error page...
Read more >
Insert text at cursor in a content editable div - Stack Overflow
The following function will insert text at the caret position and delete the existing selection. It works in all the mainstream desktop browsers:...
Read more >
Editor options (Advanced) - Microsoft Support
Editor options let you select options for your content in Outlook. ... ARROW key after you scroll, the cursor responds at the page...
Read more >
API - Quill Rich Text Editor
Changes to text may cause changes to the selection (ex. typing advances the cursor), however during the text-change handler, the selection is not...
Read more >
Updating Fields in Word – How it Works - DocTools
Why does Word not update all fields when I select all and press F9 to ... You can read more about the different...
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