storedMarks being reset on click? (working on toolbar implementation)

So, I’m working on an accessible toolbar implementation - I’ve got a rough beta up here: (there’s some unhandled edge cases for the editor, and image upload right now is only embedded data URI so uh, don’t upload anything big).

Keyboard navigation is actually working pretty solidly, but I’ve noticed an issue with mouse navigation. If you select a mark in the toolbar, and then use tab to move focus into the editor and start typing, it correctly applies the selected marks to the input (or vice versa if you cleared marks inside a marked block). However, if you click inside the editor area, the stored marks are reset (it looks like click causes the update cycle to run, and focus doesn’t, which may be related?).

The demo toolbar code appears to have the same issue, so I don’t think I’ve broken anything in my code.

This is why most toolbars use the mousedown event (which runs before focus moves to the clicked element) and preventDefault it. Or call .focus() on the editor after applying their effect.

Moving the selection resets stored marks. Clicking explicitly moves the selection to the position you click.

Ahhh, that makes sense, thank you for the explanation! I’ll play around with intercepting the events.