-
Notifications
You must be signed in to change notification settings - Fork 22.6k
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
Add link to cancel event to HTMLInputElement page #30946
Conversation
Preview URLs Flaws (45)URL:
(comment last updated: 2023-12-15 06:32:58) |
Fixes mdn/mdn#490 That should work. FYI only, best to just create MDN issues related to content into this repo. |
@wbamberg @teoli2003 Unlike methods and properties, the interface template for Events does not refer to parent interfaces for inherited events: https://developer.mozilla.org/en-US/docs/MDN/Writing_guidelines/Page_structures/Page_types/API_reference_page_template#events Does that mean that the events listed in an interface are "the full set" that can be applied to the interface? If so, this PR is absolutely correct. If not, how do we deal with this case? As an aside, the HTML tag page should have a table of Events like this https://developer.mozilla.org/en-US/docs/Web/HTML/Element/video#events. The https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input does not have one. If this was created, should it list all events (I would assume so). |
Fixes #31014 |
Thanks for the ping, Hamish. I don't think we should do this. I think we should list events on the interface on which they are defined, like we do for methods and properties. What would be the rationale for doing something different for events?
I'd guess this is an oversight, and the template should be updated. I appreciate that it's a pain having to check up the hierarchy for these things, but it's a much more maintainable approach, and it probably more usable overall than having huge lists of duplicated events. |
@wbamberg I tend to agree. Though this appears to be inconsistent with what is supposed to be done in the HTML element documentation - such as https://developer.mozilla.org/en-US/docs/Web/HTML/Element/video#events Anyway, it would not be inconsistent to cross link to the corresponding information in the HTML tag for more information about the events. OR we have to reconsider how we do that too. |
Not sure if it might help for me to explain why I wanted to add this documentation. I've wanted this event to exist for a few years, but didn't know it exists. Just recently, I ran into another use case where I wanted the functionality is provides. My first port of call for documentation is MDN, so that's where I went to see if there was a way to detect when a file input's prompt is dismissed without selecting anything. I now know that this event is documented on the I only discovered the event existed when I went to suggest it as an addition to the HTML standard, and found the issue where it had been suggested back in 2021. I also think it would be consistent with other documentation to mention this event on the Though it exists on the The documentation on the |
Use macros Co-authored-by: skyclouds2001 <[email protected]>
Yes, it is. We should add a sentence here. |
For example, adding a sentence in the template just before the events list like:
Is it better? |
And for Also, for BCD, the So, when going to https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/cancel_event, the BCD table and spec table will report it can't find data Maybe it is better to follow the behavior of BCD data. That is, create two separate pages for related spec: https://html.spec.whatwg.org/multipage/indices.html#event-cancel |
The text should be added in main content part, not in comment part |
@Cipscis , I do appreciate that it would be easier to find this if it were on the It seems like there are three options here:
If we choose "sometimes duplicate", what's the principle here? How do we decide what to do in any given case? What happens next week when someone files an issue that
@skyclouds2001 , Yes, I wondered about this too, and it sounds like a good idea. The main drawback is that it is inaccurate: Apart from wrongness being a problem in itself, it will be a problem if we ever want to use webref to extract information about specs for MDN, or to validate the reference docs we have on MDN (which we surely do), because webref attaches
@hamishwillee , yeah, it would IMO be a good thing for https://developer.mozilla.org/en-US/docs/Web/HTML/Element/dialog , in its description, to mention that cancelling the dialog fires a |
@wbamberg That's not quite what I was suggesting. The HTML element page structure template requires that you list all elements. So we'd list all elements in From HTMLDialogElement > Events we'd add the line about inherited events, remove the This is all "as per the current rules" except for having a link from events in the API to having a link in the HTML element page. PS, agree that we should follow same rule for events as properties/methods re-inheritance - "link to the parent interface". It makes no sense for anyone to create exceptions - makes things harder for authors and readers. |
yes, the BCD seems to use the targets that can fire the specific event (for but webref use the targets that can listen to the specific event (for the two is quite different on events relates with DOM |
FYI only, updated HTMLDialogElement to remove |
In practice we don't document "all events" on HTML element pages, we document some events, and again the criteria are not clear. But, one problem at a time. The HTML element pages are less structured and more chatty than the Web/API pages (a principled reason for this maybe being that there aren't nearly as many of them). So, I'm not against this. |
@wbamberg Thanks very much - you make good points. @Cipscis Do Will's arguments above make sense to you too #30946 (comment)? If so, can we close this? There is still scope to improve this information by adding the events in the https://developer.mozilla.org/en-US/docs/Web/HTML/Element/dialog or by adding an example that spells this particular case out, or both. |
It would be great to have documented on the |
@hamishwillee my main concern is making sure it's easier to find out about this "cancel" event for input elements. Obviously I'm the person here who's least familiar with the ways things are standardised when editing MDN documentation, since this is my first foray into that side of it. So if my particular suggested way of surfacing this information isn't the best, then I'd be happy to see a different approach used instead. If I understand the full discussion correctly, the alternative that's been suggested is to add a table of events to pages for HTML elements such as That solution sounds good to me, and I'd be happy for this PR to be closed in favour of that approach. Also, a bit separately to the rest of my comment, since the compatability data has come up in discussion it feels relevant for me to mention the issue I raised on the browser-compat-data repo at about the same time as I created this PR: mdn/browser-compat-data#21585 |
That ^^^ is partially what I suggested. However I wasn't proposing modifying the way that we do events in the Will was suggesting an alternative which was just to document the conditions under which cancel can be fired in its own section or example - and you might also do this in I'm not going to comment on the compatability data. I'll leave this to Will to close as assigned reviewer. |
see https://github.com/orgs/mdn/discussions/360#discussioncomment-7934242 , maybe it is a good idea here? that is - create two documentations under |
This pull request has merge conflicts that must be resolved before it can be merged. |
This seems essentially the same as your suggestion in #30946 (comment) ?
...and again, the problem is that this is incorrect, the event is defined on HTMLElement. One reason why this kind of wrongness is a bad idea is that it makes it much harder to use Web IDL to check or provide information for MDN pages. So I'm closing this PR. Happy to consider one of the suggestions Hamish mentioned in #30946 (comment). |
Description
This PR adds a link to the "cancel" event that can be used with
HTMLInputElement
to theHTMLInputElement
page.Motivation
The "cancel" event lives with the
HTMLElement
interface, but it is only used with<dialog>
elements and<input type="file">
elements. It is currently linked to on theHTMLElement
page and the<input type="file">
page, but these aren't necessarily the most obvious places to find it.Because it's a JavaScript event, I think there should be a link to it on the
HTMLInputElement
page.Additional details
Related issues and pull requests
#31014