content icon indicating copy to clipboard operation
content copied to clipboard

No information about "cancel" event on HTMLInputElement page

Open Cipscis opened this issue 1 year ago • 12 comments
trafficstars

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

Cipscis avatar Dec 15 '23 00:12 Cipscis

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

bsmth avatar Jan 24 '24 13:01 bsmth

Indeed, there's a larger discussion about where this should live in https://github.com/mdn/content/pull/30946

bsmth avatar Jan 24 '24 13:01 bsmth

Related issue on BCD open here: https://github.com/mdn/browser-compat-data/issues/21585

dipikabh avatar Jan 30 '24 04:01 dipikabh

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.

dipikabh avatar Jan 30 '24 05:01 dipikabh

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

skyclouds2001 avatar Jan 30 '24 18:01 skyclouds2001

Related: https://github.com/mdn/content/issues/31910

Josh-Cena avatar Jun 07 '24 07:06 Josh-Cena

So is the conclusion to keep the page at HTMLElement? I'm not sure what the conclusion is or if we reached one.

Josh-Cena avatar Jul 03 '24 21:07 Josh-Cena

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 HTMLInputElement and HTMLDialogElement pages to the cancel event, describing when it is fired. Readers are often looking for the event info on these subclasses.

    For example, the cancel event info has been added to the <input type="file"> page via pull/29639. Similar info or links need to be added to HTMLInputElement and HTMLDialogElement pages for improving discoverability.

dipikabh avatar Jul 08 '24 17:07 dipikabh

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.

Josh-Cena avatar Jul 08 '24 17:07 Josh-Cena

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.

Josh-Cena avatar Jul 26 '24 22:07 Josh-Cena

:+1: Agree. I think I've made a mistake, therefore we do really need these two pages to be separated.

FurryR avatar Sep 27 '24 13:09 FurryR

my research is as follows:

  • HTMLInputElement (type = 'file')

    • fired when user does not change file selection
    • bubble = true
    • cancelable = false

image

  • HTMLDialogElement

    • fired when dialog close
    • bubble = false
    • cancelable = true

image

skyclouds2001 avatar Oct 10 '24 09:10 skyclouds2001