There was behavior change with selection after inserting inline node. How to restore old behavior?
See original GitHub issueDo 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
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:
- 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)
- 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
- 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 - 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:
- Created 6 years ago
- Reactions:3
- Comments:7 (7 by maintainers)
Top GitHub Comments
@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?
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.