Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 name attribute for grouping details elements into an exclusive accordion #9400
Add name attribute for grouping details elements into an exclusive accordion #9400
Changes from all commits
c88bbf7
8639043
cba81a3
51471c9
40c8996
5134538
8d04f03
9b76787
b7042fa
b945c9c
20490af
0c64396
65a26ed
e3ede80
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, should we just suppress mutation events for these changes too??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't feel like that's necessary. I think copying a list before sending the items notifications is a reasonably common pattern (although maybe it became common because of things like mutation events).
Also, if the exclusivity enforcement is actually 100% foolproof, this isn't really even needed anymore because we could change the spec to return from the algorithm when finding the existing open details element. I'm not sure I'm ready to presume that it's 100% foolproof, although I admit I don't know how to break it.
So if I were to change something here I'd probably be inclined towards changing it to assume that the exclusivity enforcement works and just toggle the first open details that it finds and then return.
[Edit: but I'm inclined to leave it as-is.]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I meant the suggestion more from the perspective, discussed a bit at TPAC, that mutation events are bad and we should maybe take the opportunity to turn them off with new features in general. In particular, it might be more intuitive and easy to explain that "mutation events don't work with named
<details>
", instead of "mutation events don't work when inserting details might change the name, but do work for other name-related mutations".I don't feel strongly on this and am happy to leave it up to you, although @mfreed7 might also be interested.
Concretely, my suggestion is to include the flipping inside both the "ensure details exclusivity by closing other elements if needed" and "ensure details exclusivity by closing the given element if needed" algorithms, so that whenever they are called, no mutation events result. Right now it's just flipped for a single call site of the latter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've done that -- it seems reasonable to me. It does make sense from the perspective of explaining this to authors (though it does also apply the change to cases that they're more likely to hit).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for suggesting this @domenic. I agree for two reasons: first, I like the TPAC suggestion to make cool new features disable mutation events more, as a carrot. And second, as you both mentioned, it feels easier to just say "mutation events don't fire for named details" than the more complicated thing. So +1.
I'm almost inclined to re-suggest Domenic's point at TPAC - perhaps adding a
<details name>
in the page disables all mutation events for that document from that point on. That's pretty heavy-handed, so I'd understand if you don't want to do that. But I'd be supportive if you did! 😄There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is pretty heavy-handed -- that sort of interaction can make things difficult for pages that are built in modular ways and combined. I think it's dangerous for global behavior changes to come from something that looks entirely local -- if we're going to have global behavior toggles they should look global.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume you're talking more about my second paragraph ("from that point on") and not the first ("just for details mutations"), right? If so, I see your point and agree. My second paragraph was just an underhanded way to spread the pain of the mutation events deprecation. 😵💫 Nicely played avoiding that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I was replying to the second paragraph!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be good to make it clear how the behavior is different for the "ensure details exclusivity after mutation" vs. the attribute change steps. In particular, based on the name of "ensure details exclusivity after mutation", I would have assumed you could call that from the attribute change steps.
One suggestion:
details
exclusivity by removing the given element'sopen
if needed" and "ensuredetails
exclusivity by removing other elements'open
if needed". The latter will only have one call site, but I think having the two exist side-by-side is more helpful.<div class="example">
s showing the before/after of the three different scenarios: changingname=""
, changingopen=""
, and inserting a<details>
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've done this roughly as you described, with the following exceptions:
open
since I think examples should generally demonstrate good practice, and I think the handling for the other cases is really about maintaining the exclusivity invariant in the face of bad practice. (This is much of what [exclusive accordion] exclusively non-exclusive... openui/open-ui#786 was about.)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great! Can we unify the algorithm styles a little bit? Steps 2, 3, and 3.1 of "ensure details exclusivity by closing other elements if needed" are almost identical to steps 2, 3, 3.1, and 3.1.1 of "ensure details exclusivity by closing the given element if needed", but use rather different styles and wording.
I'd suggest something like:
As for the examples, I thought including the bad-case examples would be helpful for implementers to understand. I don't insist though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've done the unification you described. (It also had some interactions with the mutation events suppression.)
I think my inclination on examples is that, for implementers, having the examples in WPT is more useful than having them in the spec. :-) So I'd still lean against having them in the spec. And I think the necessary test for name attribute changes is covered in https://wpt.fyi/results/html/semantics/interactive-elements/the-details-element/name-attribute.tentative.html . I realize I need to add a test there for the insertion-while-open case.