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
There is at least one instance where codemirror triggers DOM events from within a transaction: https://github.com/codemirror/view/blob/b20446de33b34e1d4533931893b5737e1ee14eb2/src/docview.ts#L301 (calling blur() causes the blur event to be emitted synchronously). If you listen on this event and dispatch a transaction in the handler, you get the error "Calls to EditorView.update are not allowed while an update is in progress". This is surprising because you don't expect an update to be in progress when you listen on DOM events like "blur".
Can domEventHandlers check if the event occurs within a transaction, and if yes, wait until the transaction is done before it fires?
This "dispatch transaction now if possible, or after the current transaction is processing" logic could also be exposed standalone, I saw this discussion where it was suggested.
Sorry for no reproduction link - I'm not quite sure in which case the blur event is triggered, I only found these cases in our error reporting tool (and am not sure how to reproduce it).
Browser and platform
Chrome on Windows
Reproduction link
No response
The text was updated successfully, but these errors were encountered:
I'm not super comfortable introducing magic asynchronicity in a feature that should just be a thin wrapper around DOM events, but yeah, there can be spurious blur/focus events that are synchronously fired during selection update (because moving the DOM selection cannot be done without affecting focus), and I can see how they will cause problems. If you can use focus change effects instead of event handlers, that might be cleaner, but that will not work for all situations.
Describe the issue
There is at least one instance where codemirror triggers DOM events from within a transaction: https://github.com/codemirror/view/blob/b20446de33b34e1d4533931893b5737e1ee14eb2/src/docview.ts#L301 (calling
blur()
causes theblur
event to be emitted synchronously). If you listen on this event and dispatch a transaction in the handler, you get the error "Calls to EditorView.update are not allowed while an update is in progress". This is surprising because you don't expect an update to be in progress when you listen on DOM events like "blur".Can
domEventHandlers
check if the event occurs within a transaction, and if yes, wait until the transaction is done before it fires?This "dispatch transaction now if possible, or after the current transaction is processing" logic could also be exposed standalone, I saw this discussion where it was suggested.
Sorry for no reproduction link - I'm not quite sure in which case the
blur
event is triggered, I only found these cases in our error reporting tool (and am not sure how to reproduce it).Browser and platform
Chrome on Windows
Reproduction link
No response
The text was updated successfully, but these errors were encountered: