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
{{ message }}
Repository navigation
"first-input" dispatch logic in the spec doesn't match the tests and the Chromium implementation #142
Hi! I was looking at the failing tests that we have in Firefox and noticed an inconsistency between the spec and web platform tests + chromium implementation.
In Firefox, our implementation doesn't have this check as we follow the spec, and the tests are failing because of it. Either we need to update the spec and Firefox. Or we need to update the tests and Chromium (which sounds more unlikely).
If the spec needs an update, my wording recommendation would be:
Otherwise, if name is one of "click", "keydown" or "mousedown", AND if window’s pending first pointer down is null, then:
I think the best solution is for the first-input entry to be the first event which fires (according to UI Event spec).
In chromium, that is pointerdown. Is pointerdown also the first event in FF?
If so, I suggest we update the spec to remove the special language for the ordering of event types and instead to define first-input in terms of the first event which is an interaction. (I think we have an open issue to do this).
I was supposed to make changes to this text already, based on past discussions in the WG, but I had not done so yet.
If you could check, and if you agree, that the changes would better match actual web platform event dispatch behaviour also in FF, that would be ideal!
Thanks for the quick response! Looping @sefeng211 in here as well.
In chromium, that is pointerdown. Is pointerdown also the first event in FF?
Yes, that's also the case in Firefox.
I think marking the first input as first event that fires could make sense. But I was talking with @sefeng211 yesterday and he pointed out that the spec mentions that we expose the pointerdown event only if it's followed by a pointerup. (in the spec link, see below the list wording that says "pointerdown which is followed by pointerup"). I think this distinction comes from the fact that if pointerdown is followed by a pointerup it means it's a touch event and otherwise it's a mouse event.
Note that these are the order of events that are fired for a touch and for a click in Firefox (assuming it's the same in Chrome):
But I also agree with your idea of evolving this into "first interaction". I think it's more correct if we show whichever interaction event is being fired first as a first input. But would love to hear from @sefeng211 too.
The distinction is meant to ignore touch based scrolling (well, certain other flows as well, see note below).
If there is a pointerdown without a pointerup, it means there was a pointercancel instead. Although we did dispatch a pointerdown event, we do not want to consider it a first-input candidate (nor an interactionId candidate).
This could only happen on a touch device (or stylus?). And, when this happens, there should also not be a mousedown event dispatched at all (that is because mousedown is simulated on pointerup, I think).
So, I think there is no legitimate case where you could have a mousedown, but not a pointerdown+pointerup pair, and so pointerdown should always come before mousedown.
(Historically in Chromium, I think there were certain flows where this special case did cause us to accidentally report mousedown event out of order-- but in hindsight it was a mistake-- since in those cases we were accidentally reporting what was not the first input event. I think we should never hit these cases in Chromium (soon), and after settling this here and in spec, I intend to remove these special cases from Chromium entirely.)
In terms of pointerdown without pointerup --- another case we found in Chromium was that on some platforms when you hit contextmenu event this is equivalent to a pointercancel. I think on some platforms or in some cases you still also get the pointercancel event but not always-- so we treat both as a cancel signal.
I think that last time I looked, the UI Events spec was not super clear about this, and I'm not actually sure if Chromium should be fixed to fire pointercancel consistently. Depending on the answer, Event Timing may or may not want to add to the spec language the contextmenu event (I.e. I'm not sure if its just a chrome workaround...)
Thanks for the detailed answer again! I see, then considering all of these, it might be best to update the spec, and update Firefox to match this behavior. I'll be updating my patch in bugzilla to match this it. Note that we still don't have interactionId, but hopefully soon :)
I changed my patch to reflect this behavior in Firefox, but I would like to wait until either we have this in the spec, or we have a confirmation from all vendors of interop 2025 before landing it.
@canova I think we updated the spec, and you updated the FF implementation, and I'm currently working on changing the Chrome implementation, to make it so e.g. mousedown can never be FID since pointerdown will always be first (thats just one symptom from earlier in this thread-- the main solution is to always match first event-timing with non-0 interactionId)
I was wondering if you already audited or updated all the FID WPT? I can take a look if you havent, I just dont recall if this was already resolved last year...
Yes, I just checked again and I can see that both Firefox and the wpt side matches this updated behavior now. I think I did these as a part of Bug 1934683 and Bug 1948647.
Activity
mmocny commentedon Feb 19, 2025
I think the best solution is for the first-input entry to be the first event which fires (according to UI Event spec).
In chromium, that is
pointerdown. Ispointerdownalso the first event in FF?If so, I suggest we update the spec to remove the special language for the ordering of event types and instead to define first-input in terms of the first event which is an interaction. (I think we have an open issue to do this).
mmocny commentedon Feb 19, 2025
I think this is the relevant issue: #139
I was supposed to make changes to this text already, based on past discussions in the WG, but I had not done so yet.
If you could check, and if you agree, that the changes would better match actual web platform event dispatch behaviour also in FF, that would be ideal!
canova commentedon Feb 19, 2025
Thanks for the quick response! Looping @sefeng211 in here as well.
Yes, that's also the case in Firefox.
I think marking the first input as first event that fires could make sense. But I was talking with @sefeng211 yesterday and he pointed out that the spec mentions that we expose the
pointerdownevent only if it's followed by apointerup. (in the spec link, see below the list wording that says "pointerdown which is followed by pointerup"). I think this distinction comes from the fact that if pointerdown is followed by a pointerup it means it's a touch event and otherwise it's a mouse event.Note that these are the order of events that are fired for a touch and for a click in Firefox (assuming it's the same in Chrome):
But I also agree with your idea of evolving this into "first interaction". I think it's more correct if we show whichever interaction event is being fired first as a first input. But would love to hear from @sefeng211 too.
mmocny commentedon Feb 19, 2025
The distinction is meant to ignore touch based scrolling (well, certain other flows as well, see note below).
If there is a
pointerdownwithout apointerup, it means there was apointercancelinstead. Although we did dispatch apointerdownevent, we do not want to consider it afirst-inputcandidate (nor aninteractionIdcandidate).This could only happen on a touch device (or stylus?). And, when this happens, there should also not be a
mousedownevent dispatched at all (that is becausemousedownis simulated onpointerup, I think).So, I think there is no legitimate case where you could have a mousedown, but not a pointerdown+pointerup pair, and so pointerdown should always come before mousedown.
(Historically in Chromium, I think there were certain flows where this special case did cause us to accidentally report
mousedownevent out of order-- but in hindsight it was a mistake-- since in those cases we were accidentally reporting what was not the first input event. I think we should never hit these cases in Chromium (soon), and after settling this here and in spec, I intend to remove these special cases from Chromium entirely.)In terms of pointerdown without pointerup --- another case we found in Chromium was that on some platforms when you hit
contextmenuevent this is equivalent to apointercancel. I think on some platforms or in some cases you still also get thepointercancelevent but not always-- so we treat both as a cancel signal.I think that last time I looked, the UI Events spec was not super clear about this, and I'm not actually sure if Chromium should be fixed to fire pointercancel consistently. Depending on the answer, Event Timing may or may not want to add to the spec language the contextmenu event (I.e. I'm not sure if its just a chrome workaround...)
canova commentedon Feb 19, 2025
Thanks for the detailed answer again! I see, then considering all of these, it might be best to update the spec, and update Firefox to match this behavior. I'll be updating my patch in bugzilla to match this it. Note that we still don't have
interactionId, but hopefully soon :)canova commentedon Feb 20, 2025
I changed my patch to reflect this behavior in Firefox, but I would like to wait until either we have this in the spec, or we have a confirmation from all vendors of interop 2025 before landing it.
@annevk
Hi, Would you be okay with the spec change mentioned in #142 (comment)?
Fixes w3c#139 and w3c#142: First Input is First Event with InteractionId
Bug 1948647 - Do not dispatch the first-input event if there is a pen…
Bug 1948647 - Do not dispatch the first-input event if there is a pen…
Bug 1948647 - Do not dispatch the first-input event if there is a pen…
mmocny commentedon Feb 26, 2026
@canova I think we updated the spec, and you updated the FF implementation, and I'm currently working on changing the Chrome implementation, to make it so e.g. mousedown can never be FID since pointerdown will always be first (thats just one symptom from earlier in this thread-- the main solution is to always match first event-timing with non-0 interactionId)
I was wondering if you already audited or updated all the FID WPT? I can take a look if you havent, I just dont recall if this was already resolved last year...
canova commentedon Apr 14, 2026
Hey @mmocny, sorry for missing this ping!
Yes, I just checked again and I can see that both Firefox and the wpt side matches this updated behavior now. I think I did these as a part of Bug 1934683 and Bug 1948647.
mmocny commentedon Apr 14, 2026
Fantastic. Marking as closed, cheers!