Should the cursorActivity event fire when the editor value changes programmatically in blurred state?

I have a project where I’m using the cursorActivity event to ensure that the current cursor position in the editor stays visible above a fixed-position footer. (Which works great!) I encountered a bug in my approach, however, caused by the event firing even when the editor’s value is only modified programmatically, while the editor does not have focus.

The documentation says this event, “Will be fired when the cursor or selection moves, or any change is made to the editor content,” so I guess it’s working as expected, but I was surprised by this nonetheless.

I worked around it by only responding to the event when the editor has focus, but I was curious if this is intentional behavior (that is, reporting cursor activity when the editor has no focus), and if so, what it’s useful for — it seems like the cursor will almost always be reset to a new position when the editor later receives focus again.

Yes, this is intentional (and required for a lot of uses of this event).

1 Like