Re: [csswg-drafts] improve styling of <details>/<summary> elements (#9879)

The CSS Working Group just discussed `improve styling of <details>/<summary> elements`, and agreed to the following:

* `RESOLVED: Expose the <details> contents slot as either a pseudo or a ::part, as decided in a joint meeting with WHATWG`
* `RESOLVED: We desire to have no restrictions on the stylability of the display of <details> and <summary>`

<details><summary>The full IRC log of that discussion</summary>
&lt;dbaron> https://github.com/w3c/csswg-drafts/issues/9879#issuecomment-1936179742<br>
&lt;fantasai> dbaron: Most of what I'll say here is in that comment ^<br>
&lt;fantasai> dbaron: We discussed in Cupertino, and I did some prototyping since then.<br>
&lt;fantasai> dbaron: Seemed people were more comfortable with pseudo-element approach than others<br>
&lt;fantasai> dbaron: I prototyped that, also prototyped changes that allow more flexibility in what the display value of details and summary can be<br>
&lt;fantasai> dbaron: one of the major problems is that brosers restrict the display values of one or both<br>
&lt;fantasai> dbaron: restrictions on details are in the HTML spec actually<br>
&lt;fantasai> dbaron: Bramus took some passes building demos, various ways that design systems use for disclosure widgets, so that you can do those with details + CSS<br>
&lt;fantasai> dbaron: The pieces that were important to the demos were these six things<br>
&lt;fantasai> dbaron: some we've already resolved on, but not yet shipping in all engines<br>
&lt;fantasai> dbaron: 1. Changing display on details and summary<br>
&lt;fantasai> dbaron: that's technically an HTML spec problem, maybe we can record an agreement on changing<br>
&lt;fantasai> dbaron: 2. Specifying the styles that create the disclosure triangle<br>
&lt;fantasai> dbaron: this is not interoperable: chrome and firefox do one thing, and webkit does something different<br>
&lt;fantasai> dbaron: 3. Styling pieces of the widget that weren't addressable<br>
&lt;fantasai> dbaron: I prototyped 2 pseudo-elements, ::details-summary and ::details-content<br>
&lt;fantasai> dbaron: these address pieces already described in HTML spec<br>
&lt;fantasai> dbaron: I removed ::details-summary, because it wasn't useful and was just confusing<br>
&lt;fantasai> dbaron: since there's already an element there<br>
&lt;fantasai> dbaron: ::details-content wraps the rest of the content<br>
&lt;fantasai> dbaron: I hope we can resolve to add<br>
&lt;emilio> q+<br>
&lt;fantasai> dbaron: Next is 3 pieces related to animation, super common<br>
&lt;fantasai> dbaron: When Bramus built demos, two features from Transitions L2 and Interop 2024 are well on the path of shipping<br>
&lt;fantasai> dbaron: transition-behavior property<br>
&lt;fantasai> dbaron: Last piece resolved to draft into Values 5, transition to/from `auto` heights<br>
&lt;fantasai> dbaron: was hoping to show a prototype, but not quite done<br>
&lt;fantasai> dbaron: People have wanted this in many contexts for over a decade<br>
&lt;fantasai> dbaron: separate problem that's large, not in Bramus's demos, but important piece of the puzzle<br>
&lt;astearns> ack emilio<br>
&lt;fantasai> emilio: Is ::details-content pseudo-element just the &lt;slot> ?<br>
&lt;Rossen_> q?<br>
&lt;nicole> q+<br>
&lt;fantasai> emilio: alternative would be that the author wraps a bunch of stuff<br>
&lt;fantasai> dbaron: yes, and ability to write generic styles, I think it's better if author doesn't have to write extra markup<br>
&lt;fantasai> emilio: given spec uses shadow DOM, maybe use ::part<br>
&lt;fantasai> dbaron: that's the discussion from Cupertion<br>
&lt;astearns> ack nicole<br>
&lt;fantasai> s/tion/tino/<br>
&lt;fantasai> nicole: Do other engines have a good way to do transitions to/from auto?<br>
&lt;fantasai> dbaron: of the 6 things on the list, that's the proposal in the earliest stage<br>
&lt;fantasai> dbaron: we drafted into the ED last Friday, and prototyping now<br>
&lt;fantasai> dbaron: There are a bunch of things that we need to experiment with as part of prototyping<br>
&lt;oriol> q+<br>
&lt;fantasai> dbaron: Don't want to discourage other implementations trying, but currently just trying to figure things out with the prototype now<br>
&lt;fantasai> iank_: probably doable but slightly more work in other engines, but not 10x factor, maybe 2-3x factor<br>
&lt;fantasai> dbaron: layout side requires some refactoring of existing height calculation code<br>
&lt;fantasai> dbaron: Chromium's engine was recently written, so maybe other engines need more refactoring<br>
&lt;fantasai> nicole: ...<br>
&lt;fantasai> emilio: Everything is doable...<br>
&lt;fantasai> emilio: Whatever people do for disclosure widgets now to transition to/from `auto`, I guess you can do with JS as well<br>
&lt;fantasai> emilio: so open the thing, measure it, then close it and animate to what you measured<br>
&lt;fantasai> nicole: or slide it down so it looks like growing but not<br>
&lt;fantasai> emilio: can do it now with JS<br>
&lt;fantasai> dbaron: make it easier to do<br>
&lt;fantasai> emilio: The first 3 things are not possible even without JS, so those are more important to me in terms of relative priority<br>
&lt;fantasai> nicole: a lot of developers won't use a thing that can't be animated<br>
&lt;fantasai> emilio: but already can animate as well as you can animate other things<br>
&lt;fantasai> dbaron: these things are somewhat separable, they are pieces of the puzzle to make styling these better<br>
&lt;fantasai> dbaron: some more necessary than others<br>
&lt;fantasai> emilio: first 3 things give you the static styling that you want<br>
&lt;fantasai> emilio: 4-5-6 allow declarative animations, but even now could use JS<br>
&lt;fantasai> emilio: 1-2-3 gives you what you can build right now by yourself, but with better a11y and interaction behavior<br>
&lt;fantasai> emilio: 4-5-6 just makes it easier to do animations<br>
&lt;astearns> ack oriol<br>
&lt;fantasai> oriol: Wrt ::details-summary, you thought it wasn't useful, but the &lt;summary> element can be eliminated<br>
&lt;fantasai> oriol: and then automatically generated<br>
&lt;bkardell_> q+<br>
&lt;fantasai> oriol: then might need it?<br>
&lt;astearns> zakim, close queue<br>
&lt;Zakim> ok, astearns, the speaker queue is closed<br>
&lt;fantasai> dbaron: Yes, but I can't convince myself that omitting &lt;summary> is a good practice that we should design around.<br>
&lt;fantasai> bramus: If you add some padding onto ::details-summary, doesn't work because display: contents<br>
&lt;fantasai> bramus: depending on what you do, have to target ::details-summary or summary<br>
&lt;astearns> ack bkardell_<br>
&lt;fantasai> fantasai: I think I agree with dbaron that this isn't necessary, so if we all agree, let's not go into the details.<br>
&lt;fantasai> bkardell_: The ::details-content pseudo-element, wondering if you could use it to force it open in certain layouts<br>
&lt;fantasai> dbaron: you could<br>
&lt;fantasai> dbaron: need ::details-content { display: block; content-visibility: initial; } but can force it open that way<br>
&lt;bkardell_> 🔥<br>
&lt;astearns> zakim, open queue<br>
&lt;Zakim> ok, astearns, the speaker queue is open<br>
&lt;fantasai> bramus: I used 1,3,4,6 for my demos<br>
&lt;fantasai> bramus: wrt disclosure triange, I think authors would want to be able to pick the content that they want for that triangle<br>
&lt;fantasai> emilio: couldn't you use list-style: &lt;image><br>
&lt;fantasai> dbaron: in Gecko/Blink yes; not WebKit<br>
&lt;fantasai> emilio: I think per spec you're supposed to have `display: list-item` so you can style the marker<br>
&lt;fantasai> emilio: webKit has it's own weird pseudo<br>
&lt;fantasai> +1<br>
&lt;fantasai> bramus: I haven't explored that part, I explored can we animate the details when it opens and closes<br>
&lt;fantasai> bramus: wrt basics, I tried changing layout, e.g. using flex/grid<br>
&lt;fantasai> bramus: [shows off some flexbox styles]<br>
&lt;fantasai> bramus: [shows off demo of a rectangle like [ * I am the summary |  ... blank ... ] which then grows taller and fills in sevreal paragraphs in the right half<br>
&lt;fantasai> florian: if line-clamp worked, you could make it visible and clamp it<br>
&lt;fantasai> emilio: I think this should be possible to do without fixed height<br>
&lt;fantasai> bramus: Also tried grid, using grid templates<br>
&lt;fantasai> bramus: it was really nice to use<br>
&lt;fantasai> bramus: Then I added animation, and things go tinteresting<br>
&lt;fantasai> bramus: First styling and animating the pseudo element<br>
&lt;fantasai> bramus: gave it some transition of the border between the summary and details, as well as expanding and contracting the content<br>
&lt;fantasai> bramus: might need step-end/step-start<br>
&lt;fantasai> bramus: Then I needed to transition `content-visibility`, needed allow-discrete<br>
&lt;fantasai> bramus: I wanted padding around the content as 1em, but can only add that when the element is open<br>
&lt;fantasai> dbaron: This is the difference between content-visibity and display<br>
&lt;fantasai> emilio: WebKit and Gecko use display to hide the details content, and blink uses content-visibility (which is what the spec says)<br>
&lt;fantasai> emilio: seems to me that we should get interop there relatively soon<br>
&lt;fantasai> fantasai: why content-visiblity?<br>
&lt;fantasai> emilio: so you can search its contents<br>
&lt;dholbert> scribe+<br>
&lt;dholbert> fantasai (IRC): content-visibility naming is not great for this<br>
&lt;dholbert> fantasai (IRC): ideally this would use content-visibility:collapse or something, if that existed<br>
&lt;fantasai> s/visibility/display/<br>
&lt;fantasai> bramus shows the jump when the intervening border gets removed<br>
&lt;fantasai> bramus: Also tried animating with a div instead of the pseudo<br>
&lt;fantasai> bramus: but there was a glitch towards the end<br>
&lt;fantasai> bramus: because content-visibility, I needed to force it to be visible when it's open to change the padding/height<br>
&lt;fantasai> emilio: isn't that just ecause you're using box-sizing: content-box<br>
&lt;fantasai> dbaron: even then, you still can't set it so that the content-box height is smaller than zero<br>
&lt;fantasai> bramus: another approach I styled the div, and animated the pseudo, so the pseudo acts like a curtain over the DIV<br>
&lt;fantasai> bramus: this gives the desired effect<br>
&lt;fantasai> bramus: [shows off UIKit style demo]<br>
&lt;fantasai> bramus: I was able to do this by styling the DIV and animating the pseudo on top of it<br>
&lt;fantasai> bramus: essentially same animation code throughout all the demos<br>
&lt;fantasai> bramus: [shows off horizontal accordion]<br>
&lt;fantasai> bramus: Demo for half-opened disclosure widget for "read more" / "read less"<br>
&lt;fantasai> bramus: To summarize this, setting different display modes on display/summary allows us to build out a lot of use cases<br>
&lt;fantasai> bramus: the ::details-content pseudo is necessary to make the animations, but it's kind weird<br>
&lt;fantasai> bramus: I also found it necessary to add an extra DIV to make it work<br>
&lt;fantasai> bramus: transition-behavior works nicely, and transitions to/from auto would help<br>
&lt;bramus> Links<br>
&lt;bramus> https://goo.gle/styling-details-exploration<br>
&lt;Rossen_> q?<br>
&lt;bramus> https://goo.gle/styling-details-demos<br>
&lt;fantasai> dbaron: If no one on the queue, then I will propose some resolutions!<br>
&lt;fantasai> dbaron: Propose to add ::details-content pseudo-element. No opinion about the name, but seemed reasonable<br>
&lt;emilio> q+<br>
&lt;fantasai> dbaron: In some ways I think pseudo-elements are different from pseudo-classes, because with pseudo-classes there is more value in having things common across multiple features<br>
&lt;fantasai> dbaron: but for pseudo-elements, we will want more specific names for the things we're introducing<br>
&lt;fantasai> dbaron: that's what led to the proposed name<br>
&lt;fantasai> dbaron: it's something specific to &lt;details><br>
&lt;astearns> ack emilio<br>
&lt;fantasai> nicole_: harder to be meaningful if too generic of a name<br>
&lt;fantasai> emilio: can we resolve on pseudo-element vs ::part?<br>
&lt;fantasai> emilio: seems clear that HTML spec is using shadow DOM, and if you use ::part can just do ::part(content) and don't need to be too specific<br>
&lt;fantasai> emilio: less special-casing<br>
&lt;nicole> q+<br>
&lt;fantasai> emilio: idk if we had that discussion<br>
&lt;fantasai> dbaron: we didn't resolve in Cupertino, but seemed Apple was against using ::part<br>
&lt;fantasai> dbaron: my memory was also the HTML spec editors weren't happy either<br>
&lt;fantasai> nicole: Yes, that discussion happened. There was a sense of exposing an implementation detail.<br>
&lt;fantasai> TabAtkins: we already expose that there's a shadow DOM because it has one already from the UA<br>
&lt;fantasai> dbaron: The idea was using ::part() for author-controlled shadow DOM, not for UA stuff<br>
&lt;emilio> chrishtr: html editors said that ::part() is for authors<br>
&lt;TabAtkins> chrishtr: I think the HTML editor's concern was about ::part() being an author namespace that we didn't want to get into<br>
&lt;fantasai> nicole: We would support the proposal of pseudo-elements, but not ::part()<br>
&lt;fantasai> matthieud: we don't want to expose the shadow DOM<br>
&lt;TabAtkins> TabAtkins: But there's no namespace collision issues here. Each individual shadow is its own namespace; the UA controls that shadow, so they control the parts too.<br>
&lt;fantasai> emilio: you're already exposing that information, e.g. you need to override `content-visibility` which is set on the slotp<br>
&lt;fantasai> nicole: It is unusual though. Form controls might use web components, but they don't expose their parts that way<br>
&lt;TabAtkins> TabAtkins: Plus if it's a ::part(), you can export it to your own component. Like `&lt;my-widget>&lt;::shadow>&lt;details exportparts=content>...`, then `my-widget::part(content)` works<br>
&lt;fantasai> chrishtr: Consistency with the other parts of the platform is also reasonable to have<br>
&lt;fantasai> emilio: My understanding from OpenUI was the idea of exposing components<br>
&lt;TabAtkins> (But with a custom pseudo-element, `my-widget::part(details)::details-content` does not work.)<br>
&lt;fantasai> chrishtr: OpenUI did go in that direction, and WHATWG editors didn't like it<br>
&lt;fantasai> chrishtr: to distinguish pseudo-elements provided by UA vs author<br>
&lt;fantasai> TabAtkins: We need to push back on that idea<br>
&lt;fantasai> astearns: [missed]<br>
&lt;TabAtkins> TabAtkins: If that is an accurate summary of their position, then they were making decisions based on some incorrect assumptions.<br>
&lt;fantasai> emilio: part attribute needs to be set by the engine, because it's a closed shadow tree<br>
&lt;fantasai> emilio: It's not available to authors, but it's defined in HTML spec<br>
&lt;fantasai> dbaron: I didn't try it because the discussion in Cupertino seemed so strongly against<br>
&lt;fantasai> emilio: Can we resolve to add some syntax for it, and bring ::part vs pseudo to the HTML editors/<br>
&lt;fantasai> chrishtr: We need to align on a design pattern, but how do we come to an agremeent?<br>
&lt;astearns> ack nicole<br>
&lt;fantasai> emilio: ::part is superior here in complexity and functionality<br>
&lt;fantasai> emilio: I understand being reluctant on form controls, because those left more undefined<br>
&lt;fantasai> [general confusion how to make decisions]<br>
&lt;TabAtkins> fantasai: I think I agree with Chris that it's nice to be consistent about these sorts of features.<br>
&lt;dbaron> [how to make decisions where WHATWG HTML, CSS, and OpenUI CG disagree]<br>
&lt;astearns> ack fantasai<br>
&lt;TabAtkins> fantasai: It's clear that form controls won't use ::part(), so I think it makes sense from consistency to provide a ccustom pseudo-element here too, even if you could have expressed it with ::part()<br>
&lt;emilio> q+<br>
&lt;astearns> ack dbaron<br>
&lt;TabAtkins> dbaron: I think the assumption taht form controls won't do it iwth ::part() isn't necessarily true<br>
&lt;fantasai> dbaron: Assumption that form controls don't do that isn't necessarily true, ongoing work in Open UI to build interoperable styleable form controls<br>
&lt;fantasai> dbaron: which might end up exposing ::part<br>
&lt;fantasai> dbaron: most advanced discussions are on &lt;select>, which has evolved a lot in the last 6 months<br>
&lt;astearns> ack emilio<br>
&lt;fantasai> emilio: fact that form controls don't use ::part is because we didn't have ::part when form controls were implemented<br>
&lt;fantasai> emilio: in fact, WebKit implementation itself uses a different attribute to do what part does<br>
&lt;dbaron> s/last 6 months/last 6 months, although maybe in a direction where that one in particular doesn't depend on this decision/<br>
&lt;fantasai> nicole: Fundamentally, how web developers are meant to interact with creating web content, and is there difference in built-in controls vs those created by authors<br>
&lt;fantasai> nicole: Seems clear to me that built-in controls should have simple interface, and not expose things under the shadow surface<br>
&lt;fantasai> emilio: if we do ::part, needs to be in HTML spec, so we should bring it up and get consensus there<br>
&lt;fantasai> chrishtr: So should we say that we defer to WHATWG?<br>
&lt;fantasai> astearns: We need consensus among all the implementers<br>
&lt;fantasai> emilio: We can agree on exposing the slot as either a pseudo or ::part<br>
&lt;fantasai> emilio: I don't get the argument Nicole makes, because you need to be aware of the styling of the shadow DOM in order to style these widgets<br>
&lt;fantasai> astearns: Let's resolve on exposing this as a pseudo or a ::part depending on the WHATWG discussion<br>
&lt;fantasai> emilio: it would be great to have both groups aligned<br>
&lt;fantasai> TabAtkins: I'll open an issue to centralize this discussion<br>
&lt;fantasai> emilio: Especially since this may impact future decisions as well, so we need to be clear why we're doing X rather than Y<br>
&lt;fantasai> PROPOSED: Expose the slot as either a pseudo or a ::part, depending on the WHATWG discussions<br>
&lt;fantasai> chrishtr: Let's make it clear that we'll decide in that group, and invite anyone who wants to participate<br>
&lt;fantasai> florian: Are we deferring or having a joint session?<br>
&lt;fantasai> PROPOSED: Expose the details slot as either a pseudo or a ::part, as decided in a joint meeting with WHATWG<br>
&lt;fantasai> s/slot/contents slot/<br>
&lt;fantasai> RESOLVED: Expose the &lt;details> contents slot as either a pseudo or a ::part, as decided in a joint meeting with WHATWG<br>
&lt;fantasai> dbaron: We would like display of details and summary to be as styleable as possible<br>
&lt;fantasai> Various: Yes, please.<br>
&lt;emilio> q+<br>
&lt;fantasai> chrishtr: As far as you see, there should be no restriction?<br>
&lt;fantasai> dbaron: I don't see any reason for restrictions. We might find Web-compat reasons.<br>
&lt;astearns> ack emilio<br>
&lt;fantasai> dbaron: I don't think any technical reasons other than compat<br>
&lt;fantasai> emilio: Ironically, the reason for this restriction was because not all implementations were not using shadow DOM<br>
&lt;emilio> TabAtkins: yeah, flex would expose the number of child elements of the details and so on<br>
&lt;emilio> PROPOSED: We desire to have no restrictions on the stylability of the display of &lt;details> and &lt;summary><br>
&lt;emilio> RESOLVED: We desire to have no restrictions on the stylability of the display of &lt;details> and &lt;summary><br>
&lt;fantasai> dbaron: A few things to note about the demos, that we might want to solve<br>
&lt;fantasai> dbaron: One thing that was awkward was always needing to add `display: block` to the slot<br>
&lt;fantasai> dbaron: it is possible that we might want to make it the default<br>
&lt;emilio> q+<br>
&lt;fantasai> dbaron: yes, &lt;slot> is display: contents; but maybe for &lt;details> element maybe we make it `display: block`<br>
&lt;astearns> ack emilio<br>
&lt;fantasai> emilio: I think we should decide on this soon<br>
&lt;fantasai> emilio: if you had a flex details, that changes the number of flex items<br>
&lt;fantasai> emilio: so we should go one way or the other before we ship unrestricted display<br>
&lt;fantasai> emilio: would be ironic if it's needed for compat<br>
&lt;fantasai> emilio: I'm not opposed, might be use cases for turning back to `display: contents`<br>
&lt;fantasai> chrishtr: he's not proposing to require, just change the default<br>
&lt;fantasai> bramus: for authors it'll be less surprising<br>
&lt;fantasai> emilio: we need to ship content-visibility details first<br>
&lt;fantasai> dbaron: I think all engines do it in terms of shadow DOM, and &lt;slot> defaults to `display: contents`<br>
&lt;fantasai> emilio: ...<br>
&lt;fantasai> dbaron: I should look into whether this is changeable<br>
&lt;fantasai> dbaron: Another issue was border and padding messing up the animation. I don't have an answer, but it seemed annoying repeatedly<br>
</details>


-- 
GitHub Notification of comment by css-meeting-bot
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/9879#issuecomment-1942785500 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Tuesday, 13 February 2024 23:06:10 UTC