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.

There was behavior change with selection after inserting inline node. How to restore old behavior?

See original GitHub issue

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

I suppose it’s a bug since it’s a breaking change that was unwanted because it broke my particular code, but it is beta and perhaps the change was intended and the old behavior was actually the bug so I’m not sure.

What’s the current behavior?

With latest (slate 0.31.7 slate-react 0.10.22) the text is added to the text node after the inline node

What’s the expected behavior?

With slate 0.31.3 slate-react 0.10.11 when you inserted an inline node and then continued typing, the text would be added to the text node within the inline node you inserted

http://recordit.co/FtoTMFdq1E

Working (Old slate): https://jsfiddle.net/mattmazzola/drzuL564/4/ (It seems jsfiddle doesn’t save the change to external resources so you might have to manally update them to specific package versions 0.31.3 and 0.10.11)

Broken (Latest slate): https://jsfiddle.net/mattmazzola/d2geoc8h/3/

Two main questions:

  1. Is this breaking change intended? (I assume this is still beta so semver isn’t really in affect yet and breaking changes could be expected)
  2. If no, then I assume there will be anothe PR to revert this or restore old behavior. If yes, how do I achieve the old behavior with latest slate?

My analysis is that the editor starts like: text

  1. You insert inline node with text node. I’m using parentheses to designate nested node: text, inline ( text ), text <- notice slate alway ensures there is ending text node even if it’s empty
  2. User continues typing

Here is there behavior diverges ( in old code it would be continuing on the inserted text node On the new code I suspected it was continuing on the ending text node

However, the confusion for me is that I tried using collapseToEndOfPreviousText() to restore old behavior but that doesn’t work either.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:3
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
Rebuluscommented, Jan 15, 2018

@ianstormtaylor it would be good to have possibility to change default behaviors in After plugin, which is specified in Slate. Because, as we see, in some situations, we need different behavior, but Slate doesn’t allow it. What do you think about that and how it could be possible?

0reactions
ianstormtaylorcommented, Nov 28, 2019

I believe that this may be fixed by https://github.com/ianstormtaylor/slate/pull/3093, which has changed a lot of the logic in Slate and slate-react especially. I’m going to close this out, but as always, feel free to open a new issue if it persists for you. Thanks for understanding.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Reference manual - ProseMirror
Replace the selection with the given node. When inheritMarks is true and the content is inline, it inherits the marks from the place...
Read more >
Behavior changes: Apps targeting Android 12
Learn about changes in Android 12 that will affect apps when they target Android 12. ... The following behavior changes apply exclusively to...
Read more >
Changes in merge requests - GitLab Docs
Select Preferences. Scroll to the Behavior section and select the Show one file at a time on merge request's Changes tab checkbox. Select...
Read more >
Why the Hell Would I Use Node.js? A Case-by-case Tutorial
js, you can create classic web applications on the server side. While possible, this request-response paradigm in which Node.js would carry rendered HTML...
Read more >
revert - CSS: Cascading Style Sheets - MDN Web Docs
Reverting all values is useful in a situation where you've made several style changes and then you want to revert to the browser...
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