-
Notifications
You must be signed in to change notification settings - Fork 666
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
[css-anchor-position-1] Allow anchor references to match names in outer tree scopes #9408
Comments
Minor correction: when Also, with the proposal, we can solve everything nicely without breaking encapsulation regardless of how deep the shadow tree nesting is, by passing the anchor name into the custom element via a custom property. For example: <custom-element style="--custom-element-anchor-name: --anchor-1">
#shadow-root
<div class="anchored"></div>
<style>
.anchored { inset-block-start: anchor(var(--custom-element-anchor-name) top); }
</style>
</custom-element> |
Seeing how chrome is about to ship, is there any possible way to get shadow dom support at all? This makes css anchor positioning effectively useless for web components. cc @tabatkins who touched this last for routing |
+1 for ShadowDOM support. we have an internal utility called It supports setting an arbitrary Without cross-root anchoring, it feels like anchored region would do very little to replace our current usage of Floating UI because it cannot accept arbitrary anchors. or at the very least, anchors from "parent" DOM trees. |
This issue seems so much like accessibility with shadow roots, if it's not included by default it could be years before it's possible to get enough weight behind a productive solution. We should take care not to ship something to the web platform that doesn't support all of the web platform! To that end, it would be great to find some API that allowed these two examples to delivery roughly the same: https://codepen.io/Westbrook/pen/qBGEbdE Luckily there is some prior art to lean on here. Take for instance Some things that I could certainly see as important to work out in this context: Unmanaged sharing
I'm not sure there are good or performance answers to these questions but they should be discussed well before something in this realm hits "stable". Managed sharing
I look forward to seeing this make its way into the larger conversation before any "stable" API is marketed to the larger web development community as ready to go! |
i agree on this, having to think about exceptions / and caveats or not even being able to use something because its excluded from ShadowDOM is far from ideal. |
another +1 for considering shadow roots for anchor positioning. as a larger issue, is there a recommended way that shadow root / cross root functionality can become part of the requirements of new (existing too?) proposals? it seems like a fairly common concern that shadow roots be taken into account for new css features. |
A strong +1 to echo this requirement. Without full shadow dom support, CSS anchor roots are a no-go for Material Web Components. 😞 |
I would be very sad to see new features that I can't use as a web component author. The design system I work with has a popout feature similar to the Shoelace one. |
@tabatkins can you comment on your reasons for moving this issue to level 2? Is this something we could bring back in to level 1? |
What about new functions? Something like .positioned-notice {
position-anchor: crossrootall(--anchor-el);
}
.positioned-notice2 {
top: anchor(crossrootupward(--anchor-el));
} where here
and where here
and imagine |
Anchor names and references are both tree scoped.
Currently, we only allow exact matches. In other words, anchor names can only be referenced in tree scopes where they are defined.
Proposal: allow anchor references in inner tree scopes to match names defined in outer tree scopes (like how we match at-rule names).
Reason:
The current way it's matched can be problematic according to feedback (@e111077), when we want elements in an inner tree scope to anchor to external anchors. For example:
Currently the only proper way to anchor the
.anchored
element against--anchor-1
is to use a::part
selector in the outer tree scope. And this won't work if.anchored
is further nested in another shadow tree, because we don't allow::part
selectors to chain.If we allow inner tree scope's references to match outer tree scope's definitions, then we can simply put
anchor(--my-anchor-1 top)
in the inner tree scope's style sheets, regardless of how deep the inner scope is.(In retrospect, we made anchor name use exact tree scope matching because we didn't know about use cases and wanted to keep implementation simple, see #7916 (comment); now we have use cases)
The text was updated successfully, but these errors were encountered: