Slate: Selecting all and then checking whether the value isEmpty throws

Created on 27 Jul 2018  Â·  9Comments  Â·  Source: ianstormtaylor/slate

Do you want to request a _feature_ or report a _bug_?


bug

What's the current behavior?


Go to: https://www.slatejs.org/#/hovering-menu

Click inside and command+a (or ctrl+a) to select all. You'll see an error.

This is coming from value.isEmpty being called in the check. I'm not sure what should change though.

What's the expected behavior?


Expected behavior would be that it selects all and does not error out.

bug ♥ help

All 9 comments

@linonetwo For some reason, that fix does not work for me.

It looks like number passed where a string is expected. Btw, what is the difference between isCollapsed (which works) and isEmpty (which fails for now)?

I think it is perhaps related to https://github.com/ianstormtaylor/slate/pull/1997.

I think I've narrowed it down to getFragmentAtRange not passing a path to splitNode. I'm still getting up to speed with paths, so wanted to put this here in case someone sees a quick fix.

@kalley splitNode is not a change method. (It is a method under the same model/node.js....) . I think the error is perhaps from somewhere else.

I think some proxy method in https://github.com/ianstormtaylor/slate/blob/master/packages/slate/src/changes/on-selection.js is not right.

This is not about a change method. This is about value.isEmpty being called after a change action in an component update call. So you have to follow the call stack from value.isEmpty, which is how I figured that the while loop is passing a number to splitNode. I just don't know enough about paths yet to figure out what should be happening.

isCollapsed is quick workaround, working isEmpty would be better ofc.

Fixed by #2012, thanks for reporting @kalley.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

varoot picture varoot  Â·  3Comments

bengotow picture bengotow  Â·  3Comments

YurkaninRyan picture YurkaninRyan  Â·  3Comments

AlexeiAndreev picture AlexeiAndreev  Â·  3Comments

ianstormtaylor picture ianstormtaylor  Â·  3Comments