Slate: Can't focus second editor with multiple editors

Created on 22 Nov 2018  路  5Comments  路  Source: ianstormtaylor/slate

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

bug

What's the current behavior?

Currently, if there are two editors, using the first one is fine, but on clicking the second, the focus jumps around and eventually returns to the first editor.

Fiddle - https://jsfiddle.net/em19dunz/
issue-slate
Firefox 63.0, Slate 44.6 (though also occurs on 42)
Version 70.0.3538.77 (Official Build) Built on Ubuntu , running on Ubuntu 16.04 (64-bit) Slate v42.2

What's the expected behavior?

That focus is given to the second editor

Most helpful comment

I see the same issue in my project.
I have two individual value store in react state, and see same issue.

All 5 comments

Would be interested in working on this, just haven't dived into slate internals yet, so make take some time.

@rjbergerud your fiddle is not right, you can't use the same initial value since it will have the same key. and your onChange isn't right either. try this https://jsfiddle.net/ghr8jx6n/. I don't think it's an actual bug on slate itself but more of usage of react to handle states.

Thanks, this looks like it solves the issue.

you can't use the same initial value since it will have the same key
Could you explain this more?

Value.fromJSON will generate keys for all the nodes that slate-react use to render and selection. if you use one const value = Value.fromJSON(blah) to be value for two different editors then the editor that got rendered second in the rendering order can't be focused as it will find the dom node from the first rendered editor as they have the same data-key attributes if that makes sense to you @rjbergerud

I see the same issue in my project.
I have two individual value store in react state, and see same issue.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

JSH3R0 picture JSH3R0  路  3Comments

yalu picture yalu  路  3Comments

YurkaninRyan picture YurkaninRyan  路  3Comments

bunterWolf picture bunterWolf  路  3Comments

ianstormtaylor picture ianstormtaylor  路  3Comments