You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In general using "Enter" on a toolbar that makes changes to lexical is problematic.
Lets say I have a button that toggles "bold" and it's triggered using the "Enter" key on the mouse-down event which calls dispatchCommand(FORMAT_TEXT_COMMAND...) - this causes lexical to get focus and then handle the Enter key which can replace the selected text with a new line.
adding the e.preventDefault to the event solves this problem but the focus still moves from the toolbar to the editor.
I'm also noticing a lack of focus indicators on the toolbar items. I can address that as part of this issue.
The other thing I'm thinking about is how to tab to the toolbar and the popover menu once inside the rich text editor. Currently once you're in the editor, there's no way to tab out of it, since it just inserts or removes tab characters. Pressing escape resets focus to the top of the page, but perhaps we could use the escape key to move focus to the content editable element itself, or to the toolbar?
We should also make sure it's possible to tab past the editor without getting trapped by it. WCAG 2.1.2 No Keyboard Trap (Level A) would seem to apply. For situations where the editor is not the main use of the page, such as a comment box, we'd want to make sure the user can navigate past it to other items further down the page.
Keyboard trap isn't even the default behavior, the TabIndentationPlugin takes over the tab key's default behavior. If you want tab to work like other html inputs then just don't use that plugin.
If you want tab or escape to do something other than their default behaviors, then you can write a command listener to handle that according to your editor's needs.
Ah, I see about the tab plugin, explains a lot. I think ideally the TabIndentationPlugin could still be modified to support keyboard-only users. If you'd be willing to entertain a PR for that as part of this or a separate issue, I can look into implementing that.
I also notice the toolbar isn't managing focus around dropdown menus, i.e. returning focus when closing or clicked. Same with modals.
We might also consider switching the toolbar to an arrow key navigation pattern, and use role="toolbar" as a best practice.
Activity
simon0x1800 commentedon May 3, 2025
@roeycohen Hey Can I get Assigned to this issue
etrepum commentedon May 3, 2025
When/if you have a fix for the issue, simply submit a PR. No need for assignment.
KaiPrince commentedon Sep 3, 2025
I'm also noticing a lack of focus indicators on the toolbar items. I can address that as part of this issue.
The other thing I'm thinking about is how to tab to the toolbar and the popover menu once inside the rich text editor. Currently once you're in the editor, there's no way to tab out of it, since it just inserts or removes tab characters. Pressing escape resets focus to the top of the page, but perhaps we could use the escape key to move focus to the content editable element itself, or to the toolbar?
We should also make sure it's possible to tab past the editor without getting trapped by it. WCAG 2.1.2 No Keyboard Trap (Level A) would seem to apply. For situations where the editor is not the main use of the page, such as a comment box, we'd want to make sure the user can navigate past it to other items further down the page.
etrepum commentedon Sep 3, 2025
Keyboard trap isn't even the default behavior, the TabIndentationPlugin takes over the tab key's default behavior. If you want tab to work like other html inputs then just don't use that plugin.
If you want tab or escape to do something other than their default behaviors, then you can write a command listener to handle that according to your editor's needs.
KaiPrince commentedon Sep 4, 2025
Ah, I see about the tab plugin, explains a lot. I think ideally the TabIndentationPlugin could still be modified to support keyboard-only users. If you'd be willing to entertain a PR for that as part of this or a separate issue, I can look into implementing that.
I also notice the toolbar isn't managing focus around dropdown menus, i.e. returning focus when closing or clicked. Same with modals.
We might also consider switching the toolbar to an arrow key navigation pattern, and use
role="toolbar"as a best practice.etrepum commentedon Sep 4, 2025
I think any improvements would be welcome, especially if they don't break compatibility (e.g. opt-in to changes in the tab plugin)