-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
[lexical-playground] Bug Fix: Disable table hover actions in read-only mode #6706
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
size-limit report 📦
|
); | ||
const isEditable = useLexicalEditable(); | ||
|
||
return isEditable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason for all the additional isEditable
checks? Wouldn't the check here suffice?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah this check is sufficient to prevent rendering the plugin when the editor is not editable, but the additional checks help with defensive programming. For example, when switching from editing to read-only mode, the main check will eventually unmount the component, but there is a brief period before the re-render completes, during this time, the internal checks ensure that not table modifications can occur. Basically preventing race conditions. For example, in a collobrative environment if one person sets the document as read-only, and at the same time another person trys to add a column before the rerendering has occurred.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good explanation, thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think the defensive programming is useful in this case, the resolved state of the document over the network should override whatever the local settings are for any specific client.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah i guess i dont really understand how collaborative editors work, I have removed the isEditable checks.
Description
Currently, the table hover actions allows users to add new rows and columns by hovering over the edges of the table, even when the editor is in read-only mode. Specifically the problems are: hover buttons are visible, interactions with the buttons are allowed, and the event handlers are active all while in read-only mode.
Changes Introduced in this PR
TableHoverActionsContainer
component returns null when the editor is not editableBefore
tables_readonly_before.mov
After
tables_readonly_after.mov