-
Notifications
You must be signed in to change notification settings - Fork 192
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
[exclusive accordion] developer poll on behavior of exclusive accordion #812
Comments
I tend to option 2, but I'd like the browser to render the first |
This is difficult, because I believe option 1 should be an option for authors. I just don’t know that I think it should be the default behavior. The problem is, the obvious way to invoke that state (given this markup pattern) is to have multiple As I typed this out, I realized I would have liked be an option for “this markup pattern seems insufficiently expressive for the stated goal(s) and should be reconsidered or replaced with something else”. Thumbs down, I guess? |
You don’t say why “ it's not reasonable for the browser to immediately enforce the idea that only one details> element in the group is open”. The browser could immediately enforce this state, couldn’t it? I haven’t been able to vote because there’s an assumption behind the question that I’m not getting yet. |
😁 - I think it's too weird for the browser to close some details after page load with no user initiation. |
A few responses to the comments above: @Schepp Agree that if we go with option 2 we probably want first rather than last to win, because of the progressive rendering effects. @callionica There's a good bit of discussion of that in #786. @brucelawson The closing in option 2 wouldn't be "after page load" -- it would be between parsing and rendering, so wouldn't be visually distinguishable from the closing happening immediately, but could be distinguishable by script that runs at the right time. |
The details collection needs a defaultDetailOpenAction CSS attribute with values of "exclusive" and "non-exclusive". When a details element opened, if the default action is exclusive, close all the others . If it's non exclusive, leave them alone and open the new one too. The same logic should apply when a new details element is added to the collection if new element is set to open. If it's inserted closed, no logic to run. |
We can take inspiration from radio buttons: inserting new pre-checked buttons does not break the consistency. The same should happen here, so only one element should remain open. Whether it's the first or the last (as for radios) find me quite neutral. |
i strongly prefer the effect of 2 but not the proposed mechanism, it feels complicated as compared to simply "once one open
[Edit: sorry, just spotted that was in fact part of the question, but it's maybe more helpful to think of it in terms than about markup and parsing necessarily just because it seems much more likely to happen via script]
okay, so secret but probably unpopular (for good reasons, not least the question above) third option: specify the whole thing as an error in markup (as written) and that it therefore is in the realms of undefined behaviour, and renderers can do whatever they like and so whether you get option 1 or 2 is entirely at the engine developers' discretion |
That would bring us back to the |
I prefer #2 if it follows the same rules as option buttons, which I believe is "last one wins", isn't it? If the fix-up happens before the DOM ready event, it should be fine for scripts to deal with. |
It doesn't only happen during parsing. If you build a one and insert it into the tree, same thing. If you change the name to create that situation, same thing. |
In option 1 users will first encounter a state that they won't be able to recreate. I think that this is unexpected and can confuse people. (and user needs come before author needs) |
@romainmenke I think the intent of option 1 is for authors to catch that there is an error easier. But that is a good point. And what if authors want to replicate this errored state again, after user interaction? And now that I think of it, option 2 could have a warning in the console to let authors know that there is an error. Although, I think that this is unusual. |
A bit of a curious aside: Namely: <details name="nested">
<summary>Life is</summary>
<details name="nested" open>
<summary>hard</summary>
<!-- this could go on even deeper -->
</details>
</details> |
@bkardell would the "having multiple |
I would prefer option 1 for debuggability. Unlike radio buttons we don’t have to indicate any “truth” being sent to a form target, so we might as well display what the author has written. I’ve lost hours over the years head-scratching over wrongly-rendered radio buttons and would not enjoy doing the same over details elements… |
That's indeed an important consideration! Seems as if this needs an orchestrating parent after all, which might be called The one feature you'd loose is being able to scatter group members wildly across the document, but what real use case would that be? |
A generic container with exclusivity set as a CSS property. For accordion behaviour, set exclusivity to true. Would make it easy to programmatically change the CSS if there was a need to switch between seeing one detail or multiple - I.e. recreating the error state. Feels more semantic than an element or a name= attribute, although would make it inconsistent with the exclusivity implemented for radio buttons. Has anyone ever (intentionally) used radio button exclusivity where the buttons couldn't be contained in a single parent - i.e. scattering the radio buttons? I can't think of any instances. This proposal would be deviating from the pattern established for radio button exclusivity, but that pattern may be flawed to start with. |
Option 1 means that the developer is respected until the visitor is, which feels like an important reality to support here. Multiple open items is a fail state after interaction, but in the initial HTML it’s easy to see that as intended. |
Option 2, and with it being the first |
Another use case besides author error or script insertion is find-in-page. In discussing this, I found a couple devs were unaware that |
Way out of scope of the survey, I know. Sorry-ish.
If that happens, it can lean on <section role="group" aria-labelledby="accName">
<details>[…]</details>
<details>[…]</details>
<details>[…]</details>
</section>
I struggle to think of one that does not risk 1.3.2 Meaningful Sequence or 2.4.3 Focus Order WCAG violations. Maybe let's not build that in. |
I'm more in favor of Option 1 for the reasons stated:
I personally feel like Option 2 would cross a boundary into a browser trying to infer the author's intent in a way that might not be accurate. And it would be hard for an author to figure out why, without digging into HTML documentation somewhere. Whereas with Option 1, if two (or more) details are open, it's immediately clear why, and easier to reason about. |
I'm in favor of (1) simply because it correctly reflects when mistakes are made by the author of the page. (2) obscures the mistake almost immediately. I agree with @chipcullen—(1) is simply more intuitive behavior. The browser should not assume intention by the author. |
A few comments:
|
As a user, I would prefer to have control over which items expand / collapse. I often want to compare two sentences in different As an author, this comment feels most intuitive
The Handling more open details than the specified max, I would do via option 2. The parent element could also specify if the first, or last items remain open after exceeding the max amount. |
No opinion, just wanted to re-stress SC 1.3.2 Meaningful Sequence and 2.4.3 Focus Order concerns as steering thoughts. |
@albertsemple I'm sorry, I'm still not sure we're on the same page. If this means that you would expect the codepen to close the others on insert because it is inserting only 1 --- that is not option #1 (in fact, it's part of the reason we're polling). Option #1 would currently leave both open (as would some other things). |
Stray thought: what if you make it generally exclusive but allow multiple summaries to be open. Specifically, clicking one closes the others but shift or ctrl or whatever clicking it opened it without closing the others. Then it gives users more control and turns the edge cases above into normal cases. |
@jimmyfrasche I don't believe that this is a feature of any of the systems surveyed in the accordion research, and I don't believe that I have ever seen that pattern either. While it seems semi-interesting, it raises several questions for me.. Can you point to one or more existing/hopefully popular examples that do this? |
No, but it contains the desired pattern while avoiding the hard problems. I wish more accordions did this because they make it very difficult to compare text in two different panels which I have had to do before as a user more than once and I usually just open up dev tools and force them open. The most exciting thing to me about this proposal was that I could write a bookmarklet to remove the name attributes when I had to do such a comparison but being able to middle click would be even simpler. |
I think people who choose Option 1 do this not because it's a better option, but because they're used to seeing it. For me, a self-fixing accordion indicates incorrectly written JavaScript, where the check for exclusivity fires after a For me, an exclusive accordion represents a book on a lectern or a binder cabinet: If you want to look at a page, you need to hide the page you're looking at. No two pages can be displayed at the same time, so it makes no sense that it would work on the Web. As such, I am all for Option 2. However, I do believe that the last element should be the one that's open, which can be explained in multiple ways:
Lastly, one could also think of HTML parsing as an imperative process.
As such, the latest state of the page corresponds to the latest |
Keeping first or last brings another interesting point of possible confusion if option 2 is used. When adding a new opened item to the end of the list, what happens?
What gets more confusing is that whichever of these might end up being true, you get the opposite interaction when adding an open item to the beginning of the list. The user stories, spec text, and documentation of option 1 are both so much less problematic than those of option 2:
|
@Westbrook can you include some snippets or links that illustrate what you mean? It seems to me we might have some confusing uses of "first" or "last" with respect to whether that is "in time" or in others "in tree order". During parse or insertion of fragments with multiple there is overlap, but, for example, whichever |
Does "last" mean "last in time" here? That would be one piece I might have missed and/or an important inclusion in the spec. That would reduce, though not fully resolve, possible confusion in this area. For example, in a visual context... Delivering this code: <details name="one" open>
<summary>A</summary>
This is A
</details>
<details name="one" open>
<summary>B</summary>
This is B
</details> Would leave While delivering this code: <details name="one" open>
<summary>B</summary>
This is B
</details>
<script>
const b = document.querySelector('details');
b.insertAdjacentHTML('beforestart',
`<details name="one" open>
<summary>A</summary>
This is A
</details>`);
</script> Would leave This feels different and less expected than what you get in |
It does in my words, though obviously there is correlation. When the document is received, the ones later in the tree are inserted later in time. But yes both cases you've said above are what feel intuitive and actually respecting what I feel I've said as a developer. I guess it seems there is not even remotely perfect agreement though (unsurprising, in fact even in terms of these kinds of polls this is lopsided because normally it is almost exactly 50/50 :)). |
Last in index order seems more intuitive to me than last in time. But how is it with radio buttons or select options? I think we should be consistent with those, as much as possible. |
Can I record a vote against exclusive accordions? They’re such a frustrating UI pattern. |
This change thoroughly enforces that at most one <details> element in a group established by the name attribute is open at a given time. This requires that we remove the open attribute during insertion into the DOM in some cases, and also that we remove the open attribute for some mutations of the name attribute. This suppresses DOM mutation events (but not toggle events, which are asynchronous) for the removals of the open attribute that result from insertion. This is based on discussion in (among other places): openui/open-ui#786 openui/open-ui#812 Bug: 1444057 Change-Id: I91313662f6fb005b461717445a69294bcb4d1a59
This change thoroughly enforces that at most one <details> element in a group established by the name attribute is open at a given time. This requires that we remove the open attribute during insertion into the DOM in some cases, and also that we remove the open attribute for some mutations of the name attribute. This suppresses DOM mutation events (but not toggle events, which are asynchronous) for the removals of the open attribute that result from insertion. This is based on discussion in (among other places): openui/open-ui#786 openui/open-ui#812 Bug: 1444057 Change-Id: I91313662f6fb005b461717445a69294bcb4d1a59
This change thoroughly enforces that at most one <details> element in a group established by the name attribute is open at a given time. This requires that we remove the open attribute during insertion into the DOM in some cases, and also that we remove the open attribute for some mutations of the name attribute. This suppresses DOM mutation events (but not toggle events, which are asynchronous) for the removals of the open attribute that result from insertion. This is based on discussion in (among other places): openui/open-ui#786 openui/open-ui#812 Bug: 1444057 Change-Id: I91313662f6fb005b461717445a69294bcb4d1a59 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4829108 Reviewed-by: Mason Freed <masonf@chromium.org> Commit-Queue: David Baron <dbaron@chromium.org> Cr-Commit-Position: refs/heads/main@{#1195601}
This change thoroughly enforces that at most one <details> element in a group established by the name attribute is open at a given time. This requires that we remove the open attribute during insertion into the DOM in some cases, and also that we remove the open attribute for some mutations of the name attribute. This suppresses DOM mutation events (but not toggle events, which are asynchronous) for the removals of the open attribute that result from insertion. This is based on discussion in (among other places): openui/open-ui#786 openui/open-ui#812 Bug: 1444057 Change-Id: I91313662f6fb005b461717445a69294bcb4d1a59 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4829108 Reviewed-by: Mason Freed <masonf@chromium.org> Commit-Queue: David Baron <dbaron@chromium.org> Cr-Commit-Position: refs/heads/main@{#1195601}
I agree with @ZoeBijl here. Exclusive accordions are largely an antipattern that should not be used. If implemented, I would expect browsers to allow users to opt out of the exclusive behavior per site and generally, similar to how autoplay can be ignored by users. That said, I think it would be good if there was a native way to build these features as there is a demand for this antipattern and when it is easy to bypass, it would increase accessibility as well as making it easy for developers to implement features requested by business or design in an accessible way. |
The reason why i chose option 1 is the following: I think the first idea is that the items should both be open as this makes sense from a visual standpoint. It could help to have all the items with an open attribute visually open at first load as a screen reader technology might pronounce them both as open? Or am i thinking about this the wrong way? Because screen readers can also be used by people who actually have visual abilities (dyslexia for example can be a use case) It seems normal that when something has the open attribute, it is also shown open. Unless i get it wrong and we let the browser actually remove the unused attribute in option number 2 |
… <details name>., a=testonly Automatic update from web-platform-tests Strictly enforce exclusive semantics for <details name>. This change thoroughly enforces that at most one <details> element in a group established by the name attribute is open at a given time. This requires that we remove the open attribute during insertion into the DOM in some cases, and also that we remove the open attribute for some mutations of the name attribute. This suppresses DOM mutation events (but not toggle events, which are asynchronous) for the removals of the open attribute that result from insertion. This is based on discussion in (among other places): openui/open-ui#786 openui/open-ui#812 Bug: 1444057 Change-Id: I91313662f6fb005b461717445a69294bcb4d1a59 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4829108 Reviewed-by: Mason Freed <masonf@chromium.org> Commit-Queue: David Baron <dbaron@chromium.org> Cr-Commit-Position: refs/heads/main@{#1195601} -- wpt-commits: ed2370ffc32409636abc9ec49b9d48dd6c36fdcc wpt-pr: 41935
… <details name>., a=testonly Automatic update from web-platform-tests Strictly enforce exclusive semantics for <details name>. This change thoroughly enforces that at most one <details> element in a group established by the name attribute is open at a given time. This requires that we remove the open attribute during insertion into the DOM in some cases, and also that we remove the open attribute for some mutations of the name attribute. This suppresses DOM mutation events (but not toggle events, which are asynchronous) for the removals of the open attribute that result from insertion. This is based on discussion in (among other places): openui/open-ui#786 openui/open-ui#812 Bug: 1444057 Change-Id: I91313662f6fb005b461717445a69294bcb4d1a59 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4829108 Reviewed-by: Mason Freed <masonfchromium.org> Commit-Queue: David Baron <dbaronchromium.org> Cr-Commit-Position: refs/heads/main{#1195601} -- wpt-commits: ed2370ffc32409636abc9ec49b9d48dd6c36fdcc wpt-pr: 41935 UltraBlame original commit: 498104795074ebf17d5698b1ef637f97a544e8e7
… <details name>., a=testonly Automatic update from web-platform-tests Strictly enforce exclusive semantics for <details name>. This change thoroughly enforces that at most one <details> element in a group established by the name attribute is open at a given time. This requires that we remove the open attribute during insertion into the DOM in some cases, and also that we remove the open attribute for some mutations of the name attribute. This suppresses DOM mutation events (but not toggle events, which are asynchronous) for the removals of the open attribute that result from insertion. This is based on discussion in (among other places): openui/open-ui#786 openui/open-ui#812 Bug: 1444057 Change-Id: I91313662f6fb005b461717445a69294bcb4d1a59 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4829108 Reviewed-by: Mason Freed <masonfchromium.org> Commit-Queue: David Baron <dbaronchromium.org> Cr-Commit-Position: refs/heads/main{#1195601} -- wpt-commits: ed2370ffc32409636abc9ec49b9d48dd6c36fdcc wpt-pr: 41935 UltraBlame original commit: 498104795074ebf17d5698b1ef637f97a544e8e7
… <details name>., a=testonly Automatic update from web-platform-tests Strictly enforce exclusive semantics for <details name>. This change thoroughly enforces that at most one <details> element in a group established by the name attribute is open at a given time. This requires that we remove the open attribute during insertion into the DOM in some cases, and also that we remove the open attribute for some mutations of the name attribute. This suppresses DOM mutation events (but not toggle events, which are asynchronous) for the removals of the open attribute that result from insertion. This is based on discussion in (among other places): openui/open-ui#786 openui/open-ui#812 Bug: 1444057 Change-Id: I91313662f6fb005b461717445a69294bcb4d1a59 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4829108 Reviewed-by: Mason Freed <masonf@chromium.org> Commit-Queue: David Baron <dbaron@chromium.org> Cr-Commit-Position: refs/heads/main@{#1195601} -- wpt-commits: ed2370ffc32409636abc9ec49b9d48dd6c36fdcc wpt-pr: 41935
… <details name>., a=testonly Automatic update from web-platform-tests Strictly enforce exclusive semantics for <details name>. This change thoroughly enforces that at most one <details> element in a group established by the name attribute is open at a given time. This requires that we remove the open attribute during insertion into the DOM in some cases, and also that we remove the open attribute for some mutations of the name attribute. This suppresses DOM mutation events (but not toggle events, which are asynchronous) for the removals of the open attribute that result from insertion. This is based on discussion in (among other places): openui/open-ui#786 openui/open-ui#812 Bug: 1444057 Change-Id: I91313662f6fb005b461717445a69294bcb4d1a59 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4829108 Reviewed-by: Mason Freed <masonfchromium.org> Commit-Queue: David Baron <dbaronchromium.org> Cr-Commit-Position: refs/heads/main{#1195601} -- wpt-commits: ed2370ffc32409636abc9ec49b9d48dd6c36fdcc wpt-pr: 41935 UltraBlame original commit: 498104795074ebf17d5698b1ef637f97a544e8e7
This should be closed now. Since there is a resolution to choose option 2. And that #786 has been closed aswell. |
This change thoroughly enforces that at most one <details> element in a group established by the name attribute is open at a given time. This requires that we remove the open attribute during insertion into the DOM in some cases, and also that we remove the open attribute for some mutations of the name attribute. This suppresses DOM mutation events (but not toggle events, which are asynchronous) for the removals of the open attribute that result from insertion. This is based on discussion in (among other places): openui/open-ui#786 openui/open-ui#812 Bug: 1444057 Change-Id: I91313662f6fb005b461717445a69294bcb4d1a59 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4829108 Reviewed-by: Mason Freed <masonf@chromium.org> Commit-Queue: David Baron <dbaron@chromium.org> Cr-Commit-Position: refs/heads/main@{#1195601}
This poll was previously discussed in #786, particularly starting from #786 (comment) . However, I'm putting the poll itself in a separate issue.
There is a proposal to add a feature to the
<details>
element in HTML by adding aname
attribute to the<details>
element. This feature would allow a set of<details>
elements to be related to each other because they have the samename
. (This is similar to<input type=radio>
elements being related based on theirname
.) The idea of this feature is that it allows multiple<details>
elements to be linked in an "exclusive accordion", where opening one of the elements closes the currently-open one. For example, this creates a group using the nameoptions
:The idea of this feature is that an exclusive accordion always has either zero or one open
<details>
elements.In this proposal, the browser helps to enforce this exclusivity idea. If a user clicks on a
<summary>
to open a<details>
element, any other already-open<details>
element in the group is closed. The same happens if a web page usessetAttribute
to change theopen
attribute or sets theopen
property on the element.Another result of the idea of the feature is that it is considered an authoring error to write HTML like this:
because two of the
<details>
elements are initially open, within a set that is intended to have at most one open. An HTML validator should report this as an error.Because the
<details>
element maintains its open/closed state as an attribute, there are cases where it's not reasonable for the browser to immediately enforce the idea that only one<details>
element in the group is open. The simplest example of such a case is the "authoring error" case above. This is also the case when<details>
elements are added or moved in the DOM by using features likeinnerHTML
orappendChild
. (There are also other related cases like handling of changes to thename
attribute.)We'd like to know what developers think should happen in these cases (such as when the HTML parser encounters the example above that involves
open
attributes on two different elements). The two main options for handling this are:<details>
element in the group is opened, which causes all the open ones to close. This means that the "exclusivity" concept is broken until either the user or a script opens a different member of the group.<details>
elements open will be visible to script for a period of time, but will get corrected before the document is visually displayed to the user. This also means that the specification will need to say that the browser picks either the first or last of the open<details>
elements as the one that was intended to be open.What do you think about these options?
Please vote with a single emoji reaction to this comment. (Or, if needed, add a comment to the issue explaining some other option or add a 👍🏼 to somebody else's comment.)
The text was updated successfully, but these errors were encountered: