-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Disallow interactive content in <summary> #2272
Comments
Hmm I just realized that wpt-stability-checker in web-platform-tests uses links in |
Maybe so, given we know at least one real-world use case for it (which just spontaneously emerged from how we ended up building out the format of the stability-checker comments—as opposed to being some synthetic demo constructed to advocate for the need). |
Maybe one path would be to add guidance in the rendering section asking UAs to make it possible to toggle the details even if the summary contains entirely interactive content? That seems to be what everyone does so far. |
Fixes #2246. This also fixes the value that the open attribute is set to to be the empty string, instead of "open", matching existing implementations. Tests at web-platform-tests/wpt#4539 show that both implementers of <details> follow these same semantics, despite there having been no spec previously. The only exception is that Blink included a being-rendered check, but that was removed; see https://bugs.chromium.org/p/chromium/issues/detail?id=681711. There's still some discussion ongoing as to whether we should change the content models to disallow interactive descendants of <summary> elements, happening in #2272.
Well... with See http://software.hixie.ch/utilities/js/live-dom-viewer/saved/4821 In Chrome/Opera/Firefox/Safari, for several of the things (but not the link), clicking also toggles the I don't know right now what correct behavior should be per spec for these cases. Should compare with elements with activation behavior in |
That's really strange. I wonder why Maybe links should be allowed, but other interactive content should not? |
@domenic (IMO, |
Fixes whatwg#2246. This also fixes the value that the open attribute is set to to be the empty string, instead of "open", matching existing implementations. Tests at web-platform-tests/wpt#4539 show that both implementers of <details> follow these same semantics, despite there having been no spec previously. The only exception is that Blink included a being-rendered check, but that was removed; see https://bugs.chromium.org/p/chromium/issues/detail?id=681711. There's still some discussion ongoing as to whether we should change the content models to disallow interactive descendants of <summary> elements, happening in whatwg#2272.
Not only interactive content, but any content within summary that has an implicit role should be prohibited. The element is treated like a button by the accessibility interfaces. However, a button has implicit |
Been meaning to respond to this issue for.... years now it appears. I've filed bugs against Chromium and Webkit because nested text fields within a summary will cause the details to open/close if the space key is pressed within the text field. https://bugs.chromium.org/p/chromium/issues/detail?id=1361983 https://bugs.webkit.org/show_bug.cgi?id=244984 That said though, this doesn't address the fact that role mappings for the summary element have resulted in unexpected or problematic behavior across browsers when using AT for years now. For instance, because MSAA/IA2 expose a summary element as a button - which is not supposed to have nested interactive elements, JAWS does not expose the nested interactive elements of the summary, or the semantics of non-interactive elements (headings) within due to the button mapping. For instance, JAWS handles the following very poorly:
The link is not discoverable at all to JAWS when navigating with its virtual cursor. If navigating to the summary element via the Tab key, JAWS announces "example text, button" as the name and role of the element. If hitting Tab key again, JAWS again announces "example text, button" even though keyboard focus is on the link. NVDA, however, paired with Firefox/Chromium browsers will continue to expose the mappings of elements within buttons, because these browsers have moved away from treating the children of button elements as presentational (dropping their semantics/mappings) to mitigate against authors incorrectly putting nested interactive elements within button elements - or in this case, doing what the spec says is allowed although the mapping for summary has made this problematic over the years. But even though the nested elements of the summary remain exposed, navigating to them with NVDA's scan mode is still not consistently possible. Tab key is essentially required to make sure one is accessing the appropriate interactive element. If I were to give a summary element an accessible name via aria-label, reaching any nested elements of the summary element becomes even more difficult as the aria-label is a signal to AT that the child content is not important. That'd just an extra wrinkle that makes the current content allowance a bit more difficult to deal with. There is more I could go on about with the various problems different AT have with the content model for summary... but that would just extend this comment out beyond what is necessary. tldr; the summary content model produces very inconsistent and sometimes just flat out broken experiences for people using AT. Potential solutions:
Very curious to people's thoughts on this, and if there are any further clarifications I might be able to help with to move a resolution to this issue along, whatever the resolution may be. |
I am for solution 1. Later we can change to 3 (after resolving w3c/aria#1440) |
For option 3 we would also need to make interaction of the inner interactive element only affect that element and not also the ancestor interactive element, somehow. But it seems like it would be useful to solve, since web pages will inevitably continue to nest interactive elements even if HTML says it's not allowed. I'm OK with option 1 until option 3 is ready. I mentioned |
This changes the content model for <summary> to have the same restriction on interactive content that is present for the content model of <button>. This affects conformance for documents but not for user agents. Fixes whatwg#2272.
i'm not sure what you're referring to as being outlawed? something to do with that webkit pr? the instance of the details element in the linked comment? if the latter, there's nothing there conflicting with the proposal? if the former, I apologize that I'm not following. |
Thanks! It was about the linked comment. I got confused between |
I will not willingly implement this in the HTML checker, because I assess that on balance this restriction will end up wasting more time of HTML developer-authors than it helps others — or end up just being widely ignored. Fundamentally, use cases for What I see in practice out in the wild is that I understand and recognize the very-real accessibility problems with allowing it, and I am in no way dismissing those as being ignorable. They are extremely important. And I know that what I will say now is as a standard cop-out we have been accused of using for many years in discussions — but it really seems like what needs to happen here is for the AT to be refined to provide the right UX for this. It seems like given the reality of widespread usage of this in practice, AT regardless already really needs to be find some way to handle this. We know usage of what this would make non-conforming has been in the wild already for years and is being used very commonly. And I can say from experience that this looks to me like the kind of case where very many (or most) developers would be very unlikely to choose to change their existing stuff just because the spec says it’s non-confoming and the HTML checker has started barking at them about it. |
appreciate much of your response @sideshowbarker . i disagree with implying this is something AT should work out - i have tried (and failed) to write a response to that which hasn't turned into a blog post in its length multiple times. I don't want to a reply that long. But the gist is that the AT is doing what it's being told - in that AT is treating So, seems that if the content model doesn't end up changing, then it would come down to revising the a11y mappings - which is truly needed anyway since there is no unified implementation for this element now. And in the meantime, it'll continue to be the responsibility of a11y practitioners and those that just 'know' to warn - in this specific instance - that while it may be valid HTML, it will result in accessibility gaps. |
Domenic pointed out https://participate.whatwg.org/agreement#signature on chat, as a real-world example. How does AT deal with the |
i can appreciate that comparison. I mean, the summary element is defined as a 'summary, caption, legend' for its details parent. Elements like label/caption/legend all provide a name for the element (labellable element, table, fieldset) that they are associated with. There are some key differences here though, per your question to how AT handle label:
Another difference between the current implementations for summary vs the above mentioned elements is that summary was never implemented to provide a labeling association to the details element / content that was exposed. The details element itself is - without specific intervention from an author - completely ignored/irrelevant to AT. Rather, the summary element effectively labels (and thus names) nothing but itself - there are both pros and cons to this which are a bit tangential to this thread - but it is another key difference for how this is being perceived/spec'd vs how it was actually implemented oh so long ago. So yes, while I can appreciate the thought that a summary is a label for its associated content, it leaves out the part that it's also expected to behave and act like a button that communicates it shows/hide that content, as well. Per the example: https://participate.whatwg.org/agreement#signature, which is quite a good one to poke at. I can tell you that different screen reader/browser pairings either don't allow the screen reader's virtual cursor to reach those nested links, or they don't make it apparent there is even a link within the summary at all (but it can be force-found using the tab key), OR the link is left out of name announcement of the summary (e.g., "if signing as an" - with no mention of 'individual')... and that's just some of the quirks. it's all rather inconsistent once nested interactive elements get involved. Now (some thoughts I've briefly shared with others in various conversations where I've been trying to figure out what could be done with these elements), If summary had been implemented where its shadow DOM was essentially:
The mention of Regardless, if it had been implemented in a way similar to this, and the button's marker could be styled (but the button itself not removed so as to consistently remain keyboard accessible / available to AT), then AT could have treated summary similar to:
And, that's generally treated just fine by AT. I am concerned that might be a larger lift than what browsers want to actually take on - and i'm sure there'd be other bumps along the road that AT would need to smooth out, that I've glossed over here. The point being more so that yes, summary could be/have been treated like a label/heading/title/caption... But it was also given the behaviors of a button to show/hide content. There was nothing then, and still nothing standardized now that really accounts for that double duty without actually implementing the separate elements that each can do these respective jobs. But that's again the other path that could be taken here in fixing this up. If the underlying implementation cannot be restructured as I mentioned above ( and again, I will absolutely call out that I'm likely making that seem a far 'easier' solution than it would be in reality), then the alternative would be to create a new role or make revisions/expansions of capabilities to an existing role which would allow for the current content model, and allow AT to be aware that the summary element could contain a simple string of text, or that there are other important structural elements / interactive elements within it. Firefox and Safari, and Chromium on macOS are all handling this element a bit differently, each with their own pros/cons in individually solving for this issue, while also introducing their own quirks. iOS Safari unfortunately is representative of what this'd be like if summary were treated as if it simply were a label... in that it exposes no role or state information at all, so there's no way for someone using VO to even know they can expand/collapse the information. That's been an issue since at least iOS 11.4 :( So yeah, that was a lot... i really do hope it was helpful... again, if HTML doesn't end up changing the allowed content model for summary - as i do understand why that'd be an issue for existing author implementations, then there are other pathways forward. It would have never really "solved" the problem anyway... but would have allowed for a way to let authors know there are problems with doing this. I'm reopening w3c/aria#939, which also links to an HTML AAM issue about this element. Seems there might be a lot of work/discussions to restart with those issues. |
I was talking with @muan about this and one thing we noticed is that mouse/keyboard users are able to activate interactive content inside Is it correct that AT users have no way of activating such content? And so the problem is that by treating If so, one other angle from which this could be tackled is by allowing AT users to interact with such interactive content inside |
I queried httparchive (total pages 12,808,711). Findings:
Limitations: Export of the first 1327 results (ordered by rank): https://docs.google.com/spreadsheets/d/1o2X2ld_S0JjYdZs2vPKNwfrAIdceiVH2HLSmo4BLYTI/edit?usp=sharing querySELECT
*
FROM (
SELECT
rb.page,
sp.rank,
ARRAY(
SELECT
match
FROM
UNNEST( REGEXP_EXTRACT_ALL(body, r'(?i)(<(?:summary)(?:\s+[^>]+)?>(?:[^<]+|<[^/]|</[^s]|</s[^u])+</summary\s*>)') ) AS match
WHERE
REGEXP_CONTAINS(match, r'(?i)(<(input|a|button|details|embed|iframe|label|select|textarea)(\s|>)|\s+tabindex\s*=\s*["\']?[^-])')
) AS filtered_match
FROM
`httparchive.response_bodies.2023_05_01_desktop` AS rb # TABLESAMPLE SYSTEM (0.1 PERCENT)
JOIN
`httparchive.summary_pages.2023_05_01_desktop` AS sp
ON
rb.page = sp.url
WHERE
rb.page = rb.url
# AND sp.rank <= 10000
)
WHERE
ARRAY_LENGTH(filtered_match) > 0
ORDER BY
rank |
Also usage of I agree with @domenic that making nested interactive content accessible in AT seems ideal. I don't expect we'll be able to make web developers not use interactive content in |
So that data compels me to even more emphatically assert that in the HTML checker, I will not willingly implement any error reporting for At that 46% rate, for any error message I were to start reporting, I expect that developers will just filter out that message (using one of Message Filtering mechanisms the checker provides to them), or else the developers will just completely ignore the messages (and likely, file bugs against the checker issue tracker asking me to make the checker just shut up about it) — or because of the annoyance of it, those developers will just completely quit using the checker (which is something I really really do not want to make them end up deciding to do). |
Given the discussion above, I've closed #9372, but I'm glad it triggered this discussion. It sounds like the path forward for improving accessibility here is somewhat complex and may involve changes to HTML-AAM (see w3c/html-aam#345), maybe ARIA (?, see w3c/aria#939), browsers, and ATs. I think @scottaohara (and hopefully others) understand how those pieces fit together a lot better than I do... |
regarding:
when the parent button doesn't do anything there's no problem, sure. but make it do something - https://codepen.io/scottohara/pen/PoxYOQQ - and that's not quite the case without further scripting by the author. This is notably different than how a link within a summary works today (so that's good at least). To the question:
It is variable. It depends on the AT in use and the browser implementation for the feature, I've already called out some of this in previous comments. But quickly: screen readers like VoiceOver on macOS and iOS, as well as JAWS on Windows cannot access the nested link within the button when using non-tab key navigation. If tabbing to the nested link, neither will announce the user has reached a link - rather the name of the button is repeated. Note that for summary, since macOS/iOS do not map summary to a button, there's no 'problem' reaching the link there. But they have their own usability / a11y issues - more on that in a bit... Other AT, like NVDA, also doesn't allow the virtual cursor to navigate within the button, but it does announce that there is a link within. e.g., the example "text link text" is announced as "text link, link text" - so there's a signal there that one can navigate in - and then get the double firing of events. (I'm thinking this is likely what HTML could help improve - ensuring that regardless of it being invalid, if a link within a button is activated, then don't allow the event to bubble up and activate the button as well). Interestingly, if a summary element contains only a link, then NVDA cannot open the details. But if the link is accompanied by static text, then this allows the summary to toggle the details, and another tab press to navigate into the summary to activate the link. And that's a good place to turn back to the usability issues of this, because we've only been talking about AT in the context of screen readers up till now. But there are other AT, and other disabilities which also are impacted by nested interactive elements. For instance, using Voice Control and asking for a number overlay to interact with a button with a nested link, a number will appear for the outer button element, but not the inner link. For a summary element, a number to activate will appear for the inner link, but not the summary (likely because with Webkit, summary is not mapped to a button, so it doesn't get included as an interactive item to show numbers for - this being a valid instance of where AT should update to fill this gap). But in both of these cases, one can't rely on the show numbers or saying "click [name of control]" to get the desired result, one would have to use other commands - like using the mouse grid feature to click on a part of the button or summary that wasn't the nested link. In the case of summary, since So all that to say that yes, there is some work that could be done to make nested interactive elements (at very least links) more consistently exposed by AT. But again, there are likely changes that need to happen in the way buttons/summaries are mapped to allow this, and then possibly further updates that AT would need to change - specifically VO and JAWS as far as screen readers are concerned, per my examples above. But in doing that, that's not going to necessarily make these things truly "accessible", they'll still likely be awkward and create usability issues depending on their implementation by authors. There is an effort in the ARIA WG to push forward a concept of secondary actions - that being a way for authors to purposefully specify that an interactive element has additional actions (which would often be visually conveyed as nested interactive). Maybe a way to close this out could be:
|
I'm more comfortable with "focusable" content restrictions in |
One bit of the issue, I think, is that a reasonable pattern one might want is a details where the arrow toggles it open/closed but the rest of the summary is normal interactive content. I presume that's essentially the mechanics authors are aiming for when they put links or inputs in summary; it's just not actually possible in the current design. "just add a switch" is often a lazy idea, but maybe that's the solution here - some way to tell the |
I attempted a data gathering run from a different data source (compare to @zcorpan's collection of HTTP Archive data in #2272 (comment)). My goal was to try to characterize the interactive content that's inside of summary a little better so that we can try to figure out what to do about it. I used cluster telemetry with trace collection and ran a Chromium patch to gather data using Chromium's implementation of the spec's "interactive content" definition, and also checking for the presence of a I'm sharing a spreadsheet of the results. A brief summary is that, of the 100,000 pages (site homepages):
|
Thanks @dbaron! My httparchive query is also for only homepages, FWIW. It's interesting you found about 9% of summary-using-pages use interactive content in summary and in httparchive it was 46%. Also in your results 0.7% use In either case, it seems it's still high enough to try to improve the experience for AT users for such pages (#2272 (comment)). |
Looking at some examples from #2272 (comment) :
I created a demo: https://software.hixie.ch/utilities/js/live-dom-viewer/saved/12116
Since most pages seem to get rid of the browser's disclosure triangle, making only the disclosure triangle expand the details by default would effectively break most pages using |
I worry making the disclosure triangle ( The size of the pointer target would decrease drastically. While this may only be mildly annoying for some, it would probably have a significant effect on the ability to navigate the site for those with a disability that effects their fine motor skills. At present, the clickable area (non-margin) of the default UA marker is well below the WCAG AA minimum target size of 24px by 24px (Firefox is about 14px square, while chromium appears to be around 11px square). Browsers would have to drastically increase the default marker size to be accessible, which has the potential to break the design of some pages.
|
Hi, sorry to necro the thread. I think I've read the thread diligently. But if I understand it correctly: summary/details often gets misused for an accordion element? The reason I'm asking is that for example when What's a good solution? I can think of three solutions myself:
Bit of a ramble and I'm not as experienced as you guys, but I would love to hear your take :) Thanks! |
I think summary and details are good for accordion. Especially since the name attribute combines the individual details into one element: https://html.spec.whatwg.org/multipage/interactive-elements.html#attr-details-name In the past, there was the problem that summary was transmitted as a button in the Accessibility API and buttons had an implicit role=none, i.e. all nested elements (which are permitted according to the HTML specification) lost their role and could therefore not be used in an accessible way. This meant that headings could no longer be perceived as headings, e.g. with a screen reader. In the meantime, however, mapping has changed: https://w3c.github.io/html-aam/#el-summary It now works better, but probably not yet perfectly with all browsers and screen readers. A workaround would be not to have the heading in the summary, but behind the summary element, so that the heading is only displayed when details is open. This also seems to make more sense to me, because otherwise the page has many headings with no content. Example:
|
That's not accurate. The The @joshuaboele As Scott noted above (and more succinctly over here), headings are allowed but UA implementations vary. Since this isn't a support forum you may want to ask for peoples' experience addressing this in a dedicated forum (social media with #a11y hashtag, A11y Slack, mailing lists, etc.). |
@dev-nicolaos re:
that's a solid concern - but there's also the solution of making the disclosure marker the button part in the shadow dom, and the rest of the summary still behave as a clickable label. this sort of 'treat the summary as a label' idea was already alluded / mentioned by simon and myself in prior comments, though. |
My concern was that giving authors a "way to tell the details to only make the indicator trigger the toggle behavior" would open up another accessibility/usability foot gun, one that could affect uses of If I'm understanding the "label-like behavior" proposal correctly, it sounds like that approach would center on changing the shadow dom browsers would use for |
without getting too much into it, if this were even something people would consider, i'd submit there should be no change to the pointer behavior. and i'd also submit that if someone were to hide the default indicator, that does not necessarily mean that the button itself would need to become hidden/inaccessible. but yeh, otherwise i'd say your concern was absolutely valid. |
https://html.spec.whatwg.org/#the-summary-element:concept-element-content-model
From #2246 -- the content model for
summary
should disallow interactive content descendants.The text was updated successfully, but these errors were encountered: