content
content copied to clipboard
No information about "cancel" event on HTMLInputElement page
MDN URL
https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement
What specific section or headline is this issue about?
Events
What information was incorrect, unhelpful, or incomplete?
The "cancel" event for the HTMLInputElement, which is fired when a picker for an input element with type "file" is cancelled without the value being changed, is not mentioned anywhere on the HTMLInputElement page.
What did you expect to see?
The HTMLInputElement page should mention the "cancel" event, and link to its documentation.
Do you have any supporting links, references, or citations?
The "cancel" event for <input type="file"> elements was added to the HTML standard in July 2021: https://github.com/whatwg/html/pull/6735
HTML spec - cancel event HTML spec - Common input element APIs
This feature has been supported by all modern browsers since May 2023. According to CanIUse, it currently has 83.62% global browser support. Support for this feature is already included in mdn/browser-compat-data and displays on the HTMLInputElement page.
Do you have anything more you want to share?
No response
As far as I remember, this is under https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/cancel_event
HTMLElement instead of specifically HTMLInputElement, although BCD puts it under HTMLInputElement: https://github.com/ntdiary/browser-compat-data/blob/main/api/HTMLInputElement.json#L201-L239
Indeed, there's a larger discussion about where this should live in https://github.com/mdn/content/pull/30946
Related issue on BCD open here: https://github.com/mdn/browser-compat-data/issues/21585
Hello @Cipscis, pinging to check if you'd be interested in opening a PR as per the approach proposed in https://github.com/mdn/content/pull/30946#issuecomment-1862136744.
I notice #29639, which tend to add the cancel event to <input> element, where move the cancel event from HTMLDialogElement to HTMLElement
This might be a unexpected fix and lack of discussion
Related: https://github.com/mdn/content/issues/31910
So is the conclusion to keep the page at HTMLElement? I'm not sure what the conclusion is or if we reached one.
The conclusion from https://github.com/mdn/content/pull/30946 was to keep the event with the defining interface HTMLElement.
I agree with the proposal in https://github.com/mdn/content/pull/30946#issuecomment-1862136744, that is:
-
Just like on the
<video>page, add Events tables to<input>and<dialog>pages. -
Add links on
HTMLInputElementandHTMLDialogElementpages to thecancelevent, describing when it is fired. Readers are often looking for the event info on these subclasses.For example, the
cancelevent info has been added to the<input type="file">page via pull/29639. Similar info or links need to be added toHTMLInputElementandHTMLDialogElementpages for improving discoverability.
I'm not entirely sure if documenting events in the HTML reference is a good idea since you are almost always listening for events in JS instead of HTML, but if we already have that precedent it sounds reasonable.
I, by chance, cycled back to this issue. I strongly believe the page move in https://github.com/mdn/content/pull/29639 should be reverted and we should have separate cancel pages for HTMLInputElement and HTMLDiaglogElement. They have entirely different firing conditions and behaviors, causing issues such as https://github.com/mdn/content/issues/31910. They even have separate BCD entries. I don't see reasons to conflate them.
:+1: Agree. I think I've made a mistake, therefore we do really need these two pages to be separated.
my research is as follows:
-
HTMLInputElement (type = 'file')
- fired when user does not change file selection
- bubble = true
- cancelable = false
-
HTMLDialogElement
- fired when dialog close
- bubble = false
- cancelable = true