The current selection can be a bit buggy when you click on Toolbar/menu item buttons depending on where they are placed. In particular the selection can disappear or become different. This post tries to solve it with a plugin:
I implemented the plugin and on the whole it works, however, there are a number of issues with it. Firstly, it overwrites the css background, which is different on each browser & OS. But depending on your schema, for me it creates a new span around the selection, which causes problems for my custom menu item commands.
Also, re-adding the selection is somewhat hacky. What’s the best way to do this? Can we use setSelection from transaction, and handle the selection before dispatching the transaction rather than after the event (as in the above plugin)? And ideally use PM native functions, rather than setting the css ourselves. Is there a simple way like setting selection.visible = true after the transaction?
Thanks very much