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

Toggling readOnly prop from true to false breaks the Editor #3321

Closed
martonlanga opened this issue Dec 13, 2019 · 6 comments · Fixed by #3388
Closed

Toggling readOnly prop from true to false breaks the Editor #3321

martonlanga opened this issue Dec 13, 2019 · 6 comments · Fixed by #3388

Comments

@martonlanga
Copy link
Contributor

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

Report a bug

What's the current behavior?

Code Sandbox
If you init the Editor with readOnly set to true, then toggle it to false, the onChange method won't be called when making changes. But you can still edit the value, and see the changes.
If you init the Editor with readOnly set to false, everything works as expected.

Slate: 0.54.2
Browser: Chrome / Firefox
OS: Mac

What's the expected behavior?

Call onChange even after toggling the readOnly prop.

Slack thread

@rockcs1992
Copy link

rockcs1992 commented Jan 12, 2020

@martonlanga I'm also struggling with this bug. Do you have any fix or any work around yet?

@martonlanga
Copy link
Contributor Author

Hey @rockcs1992, I think the only workaround for now is to init the Editor to with readOnly set to false, then change it to true.
@kena0ki made a pull request that should fix this bug, but it's still not merged :/
#3388

@rockcs1992
Copy link

@martonlanga Thanks for the update. I think I will go with your workaround at the moment. 😄

@Francesco-Lanciana
Copy link

Another workaround until #3388 is merged is that you can set a key on the Slate component to be equal to your readOnly state, this seems to force Slate into the correct state.

@martonlanga
Copy link
Contributor Author

@Francesco-Lanciana That makes sense, great workaround!

@rockcs1992
Copy link

@Francesco-Lanciana Great that works!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants