Re: [csswg-drafts] [css-anchor-position?] Introduce CSS Anchor Positioning (#7282)

The CSS Working Group just discussed `CSS Anchor Positioning`, and agreed to the following:

* `RESOLVED: ED of Anchor Positioning, editor TabAtkins iank_ jhey`

<details><summary>The full IRC log of that discussion</summary>
&lt;fantasai> Topic: CSS Anchor Positioning<br>
&lt;fantasai> github: https://github.com/w3c/csswg-drafts/issues/7282<br>
&lt;fantasai> TabAtkins: presented early idea in May<br>
&lt;fantasai> TabAtkins: continued working on it<br>
&lt;fantasai> TabAtkins: Jay has prepared a slide deck intro with details<br>
&lt;TabAtkins> s/Jay/Jhey/<br>
&lt;xfq> https://jhey-presents.netlify.app/tpac-2022/<br>
&lt;fantasai> jhey: CSS needs you! So want input on shaping where this goes<br>
&lt;fantasai> jhey: anchoring on the Web is a common pattern, very tricky, and headache for developers<br>
&lt;fantasai> ... when do I do it, how do I do it?<br>
&lt;fantasai> ... How to calculate the position, can I do it in an attriute<br>
&lt;fantasai> ... it's used for tooltips, menus, things driven by interaction<br>
&lt;fantasai> ... but the most common pattern is pop-ups, things that need to get into the top layer<br>
&lt;fantasai> jhey: Thinking of a tooltip, we have a containing viewport, and then we have the anchor thing like a tooltip, and then the anchor which is a button or something<br>
&lt;fantasai> ... and then have the arrow visually connecting the two<br>
&lt;fantasai> jhey: There are workarounds using abspos, requiring a special DOM structure involving wrappers and relpos<br>
&lt;fantasai> ... potential invalid HTML to put things inside other things<br>
&lt;fantasai> ... it'shard to scale or respond to viewport changes<br>
&lt;fantasai> ... might go with an example like this (shows code example)<br>
&lt;fantasai> ... you could go different route without a wrapper, then need to work out positoins<br>
&lt;fantasai> ... but it's hard to maintain<br>
&lt;fantasai> jhey: could use JS, but then need boilerplate, and styles are leaking into scriptland<br>
&lt;fantasai> ... then what info do you need, how to calculate offsets, etc.<br>
&lt;fantasai> ... (shows code example)<br>
&lt;fantasai> jhey: All of those solutions look the same<br>
&lt;fantasai> ... user sees it looks greatn, but dev experience is not great<br>
&lt;fantasai> ... done right this could be much better for a11y etc also<br>
&lt;fantasai> jhey: There's issues!<br>
&lt;fantasai> ... when something goes out of the viewport, if things change, how do we change? what about scrolling?<br>
&lt;fantasai> ... Lots of edge cases<br>
&lt;fantasai> jhey: Someone solved it?<br>
&lt;fantasai> ... there was one called tether.js, another popper.js<br>
&lt;fantasai> ... interactions are handled by JS, very config-heavy<br>
&lt;fantasai> ... lots of things to decide on, and another dependency to maintain<br>
&lt;emilio> q+<br>
&lt;fantasai> ... it gets the job done, but devs don't typically like adding extra JS files<br>
&lt;fantasai> jhey: Another is Floating UI, less download, but is it better to use, still extra dependency, which to use?<br>
&lt;fantasai> jhey: How about we keep the styles in the styles and use a new anchoring API?<br>
&lt;fantasai> ... we have container, viewport, tooltip<br>
&lt;fantasai> ... think about viewport like ocean, anchor is anchor , and chained to the tooltip<br>
&lt;fantasai> ... here the browser is working out hwere to put it. Not enough room for the boat here? shift it down<br>
&lt;fantasai> ... no depedencies no wrappers<br>
&lt;fantasai> jhey: We're experimenting and learning, I've got some demos here<br>
&lt;fantasai> jhey: Basic anchor, this is how it looks<br>
&lt;fantasai> ... no DOM structure required, can live anywhere<br>
&lt;fantasai> ... here I've got two boats tethered to the same anchro<br>
&lt;fantasai> ... I have an anchor name, tether to it<br>
&lt;fantasai> ... passing anchor name and use whichever position I want<br>
&lt;fantasai> ... I'm using clacl here, can use inside calc<br>
&lt;fantasai> ... and then anchor-side will get the width/height of anchor<br>
&lt;fantasai> ... browser will work out the offsets as I move things around<br>
&lt;fantasai> [What's happening slide]<br>
&lt;fantasai> jhey: Containment works as ussual, browser handles offsets for us<br>
&lt;fantasai> ... different fallback positions<br>
&lt;fantasai> ... if boat can't fit in the ocian here, then move it somewhere else<br>
&lt;fantasai> ... UA does it for me<br>
&lt;fantasai> ... use position-fallback to attach to fallback list of positions<br>
&lt;fantasai> .. can change containment, is contained by viewport or something lower in the tree<br>
&lt;fantasai> ... can clip x axis or y axis<br>
&lt;fantasai> ... or both<br>
&lt;fantasai> ... same demo again where constrained by scroller instead of allowed to leak<br>
&lt;fantasai> jhey: Things needed are things liek popups<br>
&lt;fantasai> ... being able to anchor things in the top layer<br>
&lt;fantasai> ... you can do this currently with JS solutions, but they do hit some limits<br>
&lt;fantasai> ... wrt resizing<br>
&lt;fantasai> ... Another is &lt;selectmenu><br>
&lt;fantasai> jhey: Where this gets really cool, you can do some interesting things<br>
&lt;fantasai> ... we have a chart, can use anchor positions in calc() I can tether a tooltip to the chart<br>
&lt;heycam> q+<br>
&lt;fantasai> ... and attach the min and maximum, and it'll work it out for me<br>
&lt;fantasai> ... you can use more than one anchor in your positioning<br>
&lt;fantasai> ... or anchor to highest bar or lowest bar<br>
&lt;fantasai> ... can also do nested menus, holy grail of anchoring<br>
&lt;fantasai> ... just anchor to something inside, and works well, menus squishes as viewport gets narrower<br>
&lt;fantasai> jhey: A few open questions<br>
&lt;fantasai> ... how to detect which side to put your arrow?<br>
&lt;fantasai> ... how do we scope things like position-fallback<br>
&lt;fremy> q+<br>
&lt;astearns> ack emilio<br>
&lt;fantasai> emilio: I had a question, seen a lot of ways of when viewport resizes, most of the fallback is clipping or shrinking<br>
&lt;fantasai> emilio: how easily can you do sliding fallback instead?<br>
&lt;fantasai> emilio: when container goes out of view<br>
&lt;emeyer> q+<br>
&lt;fantasai> emilio: thinking about how some native platforms and even Gecko's popups specify after position, and the way we do it, you have an anchor node and you specify the side of the anchor and the side of the popup you want to align<br>
&lt;fantasai> emilio: e.g. top left top left, woud put your item on the bottom by default<br>
&lt;fantasai> emilio: would give you various ways to figure out the final position if you don't fit<br>
&lt;fantasai> emilio: it not be so powerful with offsets, like the fancy chart anchoring was pretty cool and not sure to what extent could do<br>
&lt;fantasai> ... but for anchoring to single thing, seems much easier to reason about vs doing all the math and fallbacks yourself<br>
&lt;fantasai> ... Have you thought about that kind of API&lt; you can specify where the popup goes relative to anchor?<br>
&lt;fantasai> ... we allow customization with margins<br>
&lt;fantasai> ... so we use the top/left margin to shift in the direction you're anchored<br>
&lt;fantasai> ... so was wondering what kind of exploration you've done of this kind of space and other ways in platform<br>
&lt;fantasai> ... what Gecko does is very similar to what ??? does<br>
&lt;fremy> q- because I had the same remarks as emilio<br>
&lt;fremy> q-<br>
&lt;fantasai> ... I don't think Windows has a native  thing<br>
&lt;fantasai> iank_: We did do a more limited version of this, anchor to a single version<br>
&lt;fantasai> ... similar to what you're describing<br>
&lt;fantasai> ... we found though that yes, it covers the 60-70% case, but you start to lose out on some of the slightly more advanced cases<br>
&lt;fantasai> ... and there are cases, multiple anchoring thing, is quite useful for a number of use cases<br>
&lt;fantasai> iank: [missed example]<br>
&lt;fantasai> TabAtkins: You might wanto use min/max zero or 100%<br>
&lt;fantasai> ... or fallback 0 or 100%<br>
&lt;fantasai> ... so you're anchored to the side until anchor goes off the screen<br>
&lt;fantasai> ... Right now here with the pop up tersm, it's pretty awkward right now<br>
&lt;fantasai> ... Maybe these cases are simple enough to use syntax like you suggested<br>
&lt;fantasai> ... but this should be a reasonable case, and not require hundreds of @position-fallback rules, because that's bad<br>
&lt;fantasai> [shows content out demo]<br>
&lt;fantasai> emilio: In your example where the container shrinks, the positioned elements flips from below to on top of anchor<br>
&lt;fantasai> ... but in one example gets clipped instead of remaining in viewport<br>
&lt;fantasai> ... inside a container instead of viewport<br>
&lt;fantasai> ... if you keep shrinking, it could be kept inside, but then leaks<br>
&lt;fantasai> ... by default, authors won't test all combignations, and things will be offscreen in some cases<br>
&lt;astearns> zakim, close queue<br>
&lt;fantasai> ... so more declarative could allow UA could make sure that the positioning is on-screen<br>
&lt;Zakim> ok, astearns, the speaker queue is closed<br>
&lt;astearns> q?<br>
&lt;fantasai> iank_: any time that we tried to go, "ok, we want this behavior", there's a use case for opposite vehavior<br>
&lt;fantasai> ... some cases do actually want it fixed<br>
&lt;fantasai> iank_: hear your concern, but there's a plethora of use cases and all of them want something slightly different<br>
&lt;fantasai> ... similar argument could be made for  testing all possible screen sizes, and yeah you need to test<br>
&lt;astearns> ack heycam<br>
&lt;fantasai> heycam: Thanks for presentation, a few questions<br>
&lt;fantasai> heycam: the pop-up thing, does that always move to the top layer or not required?<br>
&lt;fantasai> TabAtkins: not required<br>
&lt;fantasai> TabAtkins: if using popup API, moves to top layer<br>
&lt;fantasai> ... but otherwise treated as abspos<br>
&lt;fantasai> iank_: The containing block, you can only reference anchors within that contianing block<br>
&lt;fantasai> ... so useful for components<br>
&lt;fantasai> ... so go to the scrolling example, here the contianing block is inside the scroller so it stays inside<br>
&lt;fantasai> heycam: One question is what happens when there are transforms between anchored thing and anchored<br>
&lt;fantasai> iank_: Similar rules, scrolling is complicated and want to talk about that separately<br>
&lt;fantasai> ... but for transforms use staticpos propagation rules, basically assume no transforms<br>
&lt;fantasai> heycam: no transforms?<br>
&lt;fantasai> emilio: transforms make a containing block for fixed descendants<br>
&lt;fantasai> iank_: thing that breaks is if you're transforming the anchor, that does break<br>
&lt;fantasai> ... there's a tradeoff here in that this is fundamentally a layout effect<br>
&lt;fantasai> ... so animating a transform, don't want to slow it down<br>
&lt;fantasai> ... there is an option to incorporate transform<br>
&lt;fantasai> heycam: what about shadow tree and visibility of names?<br>
&lt;fantasai> ... is this another example of issues around exposing names to shadow trees?<br>
&lt;fantasai> TabAtkins: yes<br>
&lt;fantasai> ... using anchor name itself isn't problematic, because it's a tree search<br>
&lt;fantasai> ... but for the fallback rule and its name, that has the same problems we have in other rules like @keyframes<br>
&lt;astearns> ack emeyer<br>
&lt;fantasai> emeyer: seems like a lot of the xamples use a lot of calc'ing,<br>
&lt;florian> +1 to emeyer<br>
&lt;fantasai> ... I wonder if anchor-side keywords in the draft, are those supposed to be ands, can they be ors?<br>
&lt;fantasai> ... so you could say somehting liek center left?<br>
&lt;fantasai> iank_: A lot of these use left/right, and haven't implemented center<br>
&lt;fantasai> ... so many oculd be replaced with left center<br>
&lt;fantasai> emeyer: So popup in the middle, wouldn't need calc?<br>
&lt;fantasai> jhey: could use percentages<br>
&lt;Bert> (For the historians: Around 1997, Håkon and I discussed floats with anchors and ‘elastic bands’, to try and keep floats near their anchors or near each other, depending on the strength of the ‘elastic’. Among the goals were sidenotes and parallel texts, such as a text and its translation. The difficulty for the author to know whether to write "see on the left" or "see on the right" was one reason we decided to postpone that feature.)<br>
&lt;fantasai> emeyer: so for simple things might not need calc()<br>
&lt;fantasai> emeyer: My other question is, am I understanding that a popup can be placed in relation to multiple anchors?<br>
&lt;fantasai> TabAtkins: yes<br>
&lt;fantasai> emeyer: so text with footnote reference in the middle, could have the footnote could be vertically center-aligned but have its edge against the column of text<br>
&lt;fantasai> TabAtkins: yes<br>
&lt;fantasai> emeyer: ok!<br>
&lt;fantasai> jhey: [missed]<br>
&lt;fantasai> astearns: So little over time<br>
&lt;iank_> q?<br>
&lt;fantasai> TabAtkins: I'd like to request resolution<br>
&lt;fantasai> ... last time was to have a UD, haven't done that yet<br>
&lt;fantasai> ... but it seems like to become an ED at this point<br>
&lt;fantasai> ... so would like to request an ED of this draft<br>
&lt;fantasai> astearns: Any objections?<br>
&lt;fantasai> [none]<br>
&lt;fantasai> [discussion of editors]<br>
&lt;fantasai> RESOLVED: ED of Anchor Positioning, editor TabAtkins iank_ jhey<br>
&lt;fantasai> astearns: Please make ED asap so we can file issueS!<br>
&lt;fantasai> iank_: I'm free to chat during break<br>
</details>


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


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

Received on Friday, 16 September 2022 17:05:13 UTC