Skip to content

[css-anchor-position-1] Last @try to display none? #9380

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

Closed
vmpstr opened this issue Sep 20, 2023 · 8 comments
Closed

[css-anchor-position-1] Last @try to display none? #9380

vmpstr opened this issue Sep 20, 2023 · 8 comments

Comments

@vmpstr
Copy link
Member

vmpstr commented Sep 20, 2023

It wasn't clear from the spec, but it would be super nice to try a bunch of layouts to see where the anchored element fits, but if it doesn't fit anywhere, don't show it. Is that possible with the current syntax proposals?

@vmpstr vmpstr changed the title [css-anchor-positioning-1] Last @try to display none? [css-anchor-position-1] Last @try to display none? Sep 20, 2023
@kizu
Copy link
Member

kizu commented Oct 6, 2023

Agree, maybe not display: none, but visibility: hidden could be nice to have. Or something like a hidden keyword if we'd go the route of position-area list of fallbacks or something similar.

Right now, a workaround for this could be to have the last @try render the element with 0x0 dimensions, and hide its content via a container query, but ideally it would be nice to have an ability to hide the element via the fallback mechanism.

@andruud
Copy link
Member

andruud commented Nov 15, 2023

We won't be able to support properties that modify the layout tree within @try. At the time we're evaluating @try, we've already decided that it has a layout box.

@tabatkins
Copy link
Member

Yeah, having the ability to just hide it when nothing fits is a necessity. visiblity: hidden would work (except that it can be overridden by its children); we don't have to worry about lingering layout effects of having it stick around, like we would with an in-flow element.

@fantasai
Copy link
Collaborator

fantasai commented Feb 8, 2024

@tabatkins and I drafted up a suggestion for a position-try-final property in #9196 (comment) , which would give the options [ always? && [ first | <<try-size>> ] ] | hide, where hide was defined as

Use the first [=position option=] (as for ''first''), but also hide the box such that it (and all of its contents) are invisible (like ''visibility: hidden'') and do not contribute to [=scrollable overflow=].

This issue is somewhat related also to the discussion in #7758

@tabatkins
Copy link
Member

I actually want to push back on this a little, now, and review what the use-case is for "just don't show me if I don't fit". When is that desired? (Assuming we already have some way of clipping you when your anchor is scrolled out of view.)

@vmpstr
Copy link
Member Author

vmpstr commented Feb 9, 2024

The example I was thinking of is positioning help text next to a input field which provides some optional information about the text field. Depending on window size, scroller positions, other content, font size, etc, etc, I may want to try a few locations and if none of them work, just don't display the optional information. The problem with simply clipping is that it may be a worse experience if there is no way to expand the displayed area to reveal the full tooltip.

In either case, I'm sure there are other ways to solve this problem in UX land, like having smaller tooltips or not clipping them. I would just find it surprising that, as an author, I don't have a way of hiding the anchored element. I imagine, in the cases where this is desired, my last try block would then be some artificially far away spot to "hide" it.

@tabatkins
Copy link
Member

Hm. I'd think you'd want to display that text some other way, but I suppose if it's optional/decorative/etc, it would be fine to just hide it, and authors do already have a guaranteed way to "hide" it themselves (by positioning in the unscrollable area).

All right, use-case accepted. ^_^

@tabatkins
Copy link
Member

This is a dupe of #7758 now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: unsorted FTF
Development

No branches or pull requests

6 participants