Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify detail value of synthetic click event #10346

Open
masayuki-nakano opened this issue May 14, 2024 · 4 comments
Open

Clarify detail value of synthetic click event #10346

masayuki-nakano opened this issue May 14, 2024 · 4 comments

Comments

@masayuki-nakano
Copy link

What is the issue with the HTML Standard?

https://html.spec.whatwg.org/multipage/webappapis.html#fire-a-click-event

Firing a click event at target means firing a synthetic pointer event named click at target.

The section nor "Firing a synthetic pointer event named e" section does not define about detail. The value is "click count" if the event name is "click". Mozilla gets a interop bug report about this. When you click an HTMLLabelElement, only Firefox sets the detail of synthetic "click" event to the source event's value. However, the other browsers set it to 0. Although the value is odd because 0-times click causes the "click" event, however, according to this comment, the value is used by React to consider whether the click event is synthetic one or user initiated one. Therefore, it may make sense Mozilla to align the behavior to the others. (Note that I've not checked the other synthetic "click" events' detail value, e.g., typing Enter on <a href="..."> and <input type="submit">.)

Ideally, there should be a new attribute to indicate whether synthetic one or not. However, it's impossible to expect that all React instances will be replaced with newer version soon. Therefore, keep using the detail for this purpose must be reasonable.

Additionally, pointerId and pointerType should also be clarified too. See my comment in the bug too.

@masayuki-nakano
Copy link
Author

And also this explanation must web developers to understand the detail value etc is copied from the original event.
https://html.spec.whatwg.org/multipage/forms.html#the-label-element:the-input-element

as if the element itself had been triggered by the user

So, this should be corrected too.

@domenic
Copy link
Member

domenic commented May 14, 2024

I think the spec is pretty clear on this already? It says to leave them at their default values, which is what other browsers are doing.

@masayuki-nakano
Copy link
Author

@domenic Thank you for quick reply!

I think the sentence in HTMLLabelElement definition made me misled at least. And Chrome uses non-default value for pointerId. They set -1 but its default is 0.

@annevk annevk changed the title Clearify detail value of synthetic click event Clarify detail value of synthetic click event May 16, 2024
@masayuki-nakano
Copy link
Author

Oh, about the pointerId, it's defined by the Pointer Events. However, it's hard to realize that from the HTML spec's definition.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants