Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only last one of multiple editors works with Balloontoolbar #1309

Closed
zbeyens opened this issue Dec 15, 2021 · 10 comments · Fixed by #1341
Closed

Only last one of multiple editors works with Balloontoolbar #1309

zbeyens opened this issue Dec 15, 2021 · 10 comments · Fixed by #1341
Labels
bug Something isn't working toolbar

Comments

@zbeyens
Copy link
Member

zbeyens commented Dec 15, 2021

Originally posted by dtslvr December 15, 2021
Hello

I have multiple editors with a unique id set that use Balloontoolbar. Unfortunately, only the toolbar of the last editor is working. I have updated plate from version 1 to 8 and now it's finally running again, but only with one rich text editor. Any idea how I can analyze this problem?

Dependencies:

"@udecode/plate": "8.3.1",
"@udecode/plate-core": "8.3.0",
"@udecode/plate-common": "7.0.2",
"slate": "0.72.0",
"slate-hyperscript": "0.67.0",
"slate-react": "0.72.0"

Thank you for any hint.
Thomas

@zbeyens zbeyens added bug Something isn't working toolbar labels Dec 15, 2021
@zbeyens
Copy link
Member Author

zbeyens commented Dec 15, 2021

@dtslvr moved here as it's a bug

@dtslvr
Copy link
Contributor

dtslvr commented Dec 23, 2021

Thank you for transforming my request to a bug report @zbeyens. Do you have a clue what is going wrong?

@moxxuk
Copy link

moxxuk commented Dec 23, 2021

Is this related to the Balloon Toolbar not working in the examples, or is that a different issue?

@seb-saletes
Copy link
Contributor

Hi @zbeyens,
Thanks for all the work as always 🙏
Do you have an ETA for this bug ? Or maybe you could give some instructions so I can try to fix it myself.
Sorry for pushing you but this bug is preventing us to use v9 in production.

@zbeyens
Copy link
Member Author

zbeyens commented Jan 9, 2022

The bug is probably in usePlateEditorState, the editor id is depending on the last focused editor

@zbeyens
Copy link
Member Author

zbeyens commented Jan 11, 2022

I've located the bug: usePlateEditorState(id) does not support dynamic id, React subscribes to the first id value then the component need to be unmount/mount again to work with dynamic id. It's tricky because we have different store + hooks for each id, and React does not play well with dynamic hooks. Workaround is to pass key={id} to the component using the hook.

@seb-saletes
Copy link
Contributor

Thanks Zbeyens ! I was following the discussion with Hideman on slack, I guessed it had something to do with our problem here

@dtslvr
Copy link
Contributor

dtslvr commented Jan 13, 2022

Thanks a lot for your efforts in this issue!

I have upgraded @udecode/plate and @udecode/plate-core to version 9.2.1. Unfortunately still the same behavior. Unique ids are passed to <Plate>. Anything else I can check?

@zbeyens
Copy link
Member Author

zbeyens commented Jan 14, 2022

The balloon toolbar works in both editors in the example, do you have the same issue?

@dtslvr
Copy link
Contributor

dtslvr commented Jan 14, 2022

The balloon toolbar works in both editors in the example, do you have the same issue?

Yes, in your example (docs), it works as expected. But I'm facing the same issue as before.

To illustrate it, I have created a live demo and a repository with the source. Inline, only the last editor is working. If you switch to Default, it's working as expected with multiple editors. I hope this example code may help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working toolbar
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants