-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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-react] Bug Fix: Make typeahead menu respect read-only mode #7185
[lexical-react] Bug Fix: Make typeahead menu respect read-only mode #7185
Conversation
- Add read-only mode check before showing typeahead menu - Add editable state listener to close menu when editor becomes read-only - Ensures emoji/mentions picker respects editor's read-only state Fixes facebook#7160
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
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.
Looks good! Confirmed the fix
const removeEditableListener = | ||
editor.registerEditableListener(editableListener); | ||
|
||
return () => { | ||
removeEditableListener(); | ||
}; |
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.
Just a nit for future reference, but this could be simpler:
const removeEditableListener = | |
editor.registerEditableListener(editableListener); | |
return () => { | |
removeEditableListener(); | |
}; | |
return editor.registerEditableListener(editableListener); |
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.
@etrepum Thanks for the nit suggestion about simplifying the editable listener cleanup! I'll keep this in mind for future PRs. Sorry about the force push - I should have left the original approved version. Would you mind re-approving when you get a chance?
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.
Well if you're here, might as well make that simplification and I'll re-approve and add it to the merge queue once the CI test run finishes :)
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.
@etrepum I've pushed the simplified editable listener change using the implicit return approach. The change removes the intermediate variables and explicit return statement, making the code more concise while maintaining the same functionality. Looking forward to your re-review. Thanks a lot for the feedback! 👍
9fef579
to
96f895f
Compare
Directly return the cleanup function from registerEditableListener in useEffect instead of storing intermediate variables. Suggested by: etrepum <[email protected]>
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.
LGTM!
Description
Currently, the typeahead menu (emoji/mentions picker) does not respect the editor's read-only mode. When the editor is in read-only mode:
This PR fixes the issue by:
Closes #7160
Test plan
Before
lexical-typeahead-menu-bug.mov
After
lexical-typeahead-fix.mov