[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 ↗︎
|
etrepum
left a comment
There was a problem hiding this comment.
Looks good! Confirmed the fix
| const removeEditableListener = | ||
| editor.registerEditableListener(editableListener); | ||
|
|
||
| return () => { | ||
| removeEditableListener(); | ||
| }; |
There was a problem hiding this comment.
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.
@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.
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.
@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 <bob@redivi.com>
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