Transaction types

hi marijn!

I’m back at React, character compositions, and controlled vs. uncontrolled editors, I assume you remember ^^
I did implement a workaround a while ago so nothing is crashing and compositions are at least mostly working. currently trying to refine the behaviour.
it looks like I’m intercepting too many or not enough transactions still. firefox and chrome work ok-ish, but in safari, the composition is always immediately ended, triggering the native compositionend event and, hence, the @codemirror/view compositionend observer. it works without intercepting transactions in the uncontrolled version.

I’m working with transaction.annotation(Transaction.userEvent) to check for user events, but there’s other transactions dispatched after the user event, matching neither of the types available on the Transaction class.
is there an easy way to figure out the type of those transactions and what they are actually doing?

it looks like not all annotations have a dedicated type, with the value prop sometimes being input.type.compose.start (or whatever user event), sometimes just a seemingly random number.

best,
peter

As in, the userEvent annotation holds a number? That doesn’t sound right. Can you show a reproduction of that?

Only transactions explicitly labeled with a user event have this annotation. Not all of them are expected to. Trying to detect whether a composition is active just from transaction metadata will not work, since code can dispatch any type of transaction at any time.

no, other annotations. sry, should have been more clear.
the input.type.compose.end is a custom thing, nothing ootb…
Screenshot 2025-04-23 at 07.46.56

Trying to detect whether a composition is active just from transaction metadata will not work, since code can dispatch any type of transaction at any time.

that’s the reason why I’m asking. I would need something reliable to detect the composition end (at least as reliable as it gets, I know it’s not always triggered by the browser…). I thought it may help to know what the in this case 1745... is.
happy for any suggestions (and once again thank you for you swift response and help!)

I suppose that’s Transaction.time.

duh, could have realised that myself…
not gonna help with the detection, whether a composition has ended, though…
is there anything else I could use for that?

I don’t think so. The editor is in the same boat, tracking some state through DOM events and hoping for the best. You’ll probably want to do the same. I assume you’re aware of composing and compositionStarted.

yeah, thx, I’m aware of those.
I was hoping you’d have something in place, but it seems to work fine if I add my own dom event observer for compositionend. in case the browser for some reason doesn’t trigger the compositionend, we’re out of luck, but that’s just the way it is for now…
thx again for your support!