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.

Bug: Can't move cursor to the end of the line that ends with an inline element followed by a single character

See original GitHub issue

Do you want to request a feature or report a bug?

Bug

What’s the current behavior?

When there is an inline element followed by a single text character at the end of a line, it’s impossible to move the cursor past the last character using the arrow keys. This can be seen on the rich text example by deleting everything except the first line and trying to go past the exclamation point: https://www.slatejs.org/examples/richtext out In the GIF, I’m only able to move past the exclamation point by using end or by leaving an extra character (at the end I left a space)

Slate: 0.59.0 Browser: all OS: Mac

What’s the expected behavior?

Cursor should be able to go past the last character

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:5
  • Comments:11 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
BrentFaresecommented, Apr 13, 2021

@BrentFarese thanks a lot for your reply! That helped a lot, I could work around by manually calling

Editor.normalize(editor, { force: true })

I am wondering if this is intended?

Just make your intialValue the below (empty text node between mentions) and your issue should go away.

const initialValue: Descendant[] = [
  {
    type: 'paragraph',
    children: [
      { text: 'Try mentioning characters, like ' },
      {
        type: 'mention',
        character: 'R2-D2',
        children: [{ text: '' }],
      },
      { text: '' },
      {
        type: 'mention',
        character: 'Mace Windu',
        children: [{ text: '' }],
      },
    ],
  },
]
1reaction
dan-leecommented, Apr 12, 2021

I don’t know if that’s the same issue, but please have a look at the following video:

https://user-images.githubusercontent.com/571589/114441984-55336f80-9bcc-11eb-97d7-7a6ba27e09e9.mov

When I refresh the page with some initial content I try to navigate the cursor with my arrow keys between and after the adjacent void elements and it doesn’t work. (as shown in the video)

After interacting with the editor, however, it works

I am not sure if this issue is related or not but I seemed familiar. Please tell me if I should create a new one or not.

initialValue
const initialValue: Descendant[] = [
  {
    type: 'paragraph',
    children: [
      { text: 'Try mentioning characters, like ' },
      {
        type: 'mention',
        character: 'R2-D2',
        children: [{ text: '' }],
      },
      {
        type: 'mention',
        character: 'Mace Windu',
        children: [{ text: '' }],
      },
    ],
  },
]
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to move cursor to end of contenteditable entity
This solution is for moving the caret to the end of a contenteditable element. It should work in all browsers which support contenteditable....
Read more >
CodeMirror 5 User Manual
Move the cursor one character right, going to the next line when hitting the end of line. goColumnLeft: Move the cursor one character...
Read more >
Inline elements - HTML: HyperText Markup Language | MDN
In this article, we'll examine HTML inline-level elements and how they differ from block-level elements.
Read more >
TextView - Android Developers
android:digits, If set, specifies that this TextView has a numeric input method and that these specific characters are the ones that it will...
Read more >
2 PL/SQL Language Fundamentals - Oracle Help Center
The byte representation of a single character is called a character code. ... end-of-line characters, which means that a single-line comment ends when...
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