Cursor Trapped in Atomic Range

I’m following the instructions for configuring atomic ranges using a MatchDecorator here. I’m using Decoration.replace to create a simple widget that sets the innerHTML to a word based on the replaced token. For instance, #abc123 might be replaced with a span containing “Red”. This works well when typing normally, but if I type “abc123”, then go back and add “#” at the beginning then my cursor ends up trapped inside of the resulting widget. Typing results in odd behavior where characters are positioned directly after the widget in reverse order without moving my cursor.
Should I expect my cursor to be moved out of the widget automatically when it is created or do I need to manually detect this scenario and move the cursor?

That’s indeed not great. Attached patch detects such a situation on text input and improves the way it is handled.

1 Like