Skip to content
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-POSITION-4] Define a way to have a dialog anchored to an element #5304

Open
gregwhitworth opened this issue Jul 9, 2020 · 3 comments
Open

Comments

@gregwhitworth
Copy link
Contributor

gregwhitworth commented Jul 9, 2020

<dael> TabAtkins: If we ever do want to attach to an element some mech is the thing being used to position non-anchor dialogs. If we switch non-anchor to fixedpos we have to figure out how to do it for non-anchored.

<dael> iank_: I think a different solution for anchoring down the road

I think we should open a separate issue for this because authors do want this capability outside of the specific <dialog> need (eg: tooltips, dropdown menus, etc). So this should be thought about sooner rather than later. In the research that @annevk shared there are many examples that are not centered and are anchored to an element. While I get the implementation concerns I'm also curious of making the dialog itself the scroller via overflow behavior is the right way. Most of the scenarios that come to mind however normally don't fit in what seems to be the primary definition (based on what is shipping) as a <dialogue>.

cc: @melanierichards

Originally posted by @gregwhitworth in #4645 (comment)

@gregwhitworth gregwhitworth changed the title Define a way to have a dialogue anchored to an element [CSS-POSITION-4] Define a way to have a dialogue anchored to an element Jul 9, 2020
@una
Copy link
Contributor

una commented Jul 9, 2020

I love this! I feel this would be a huge help for tooltips, menus, animations, and other relationship-based interactive items without using translation and hacking around positioning. This enables dynamically sized tooltips to be positioned more easily and improve linked submenu element positioning as well.

When I think of syntax for this, I am reminded of what gradients use for radial/conic positioning. I'd love to have the ability to anchor using the keywords "at top center", "at bottom center", "at left center", "at right center", "at center", "at top left", "at top right", etc. That being said, it doesn't account for logical positioning. On the same thread as radial/conic gradient placement as well, this could be percentage-based in addition to the keywords (i.e. 20% 20%)

It sounds like this might work best as a function that accepts position values.

@melanierichards
Copy link

^ A few of us were talking about anchored positioning in the context of various classes of popups. It could be interesting to have some platform-enabled automatic anchoring that could take into account both writing mode and available space to render said anchored element, in order to mimic how some rendering engines position popup parts of native elements like <select>.

If there's interest in creating a new keyword set around positioning, component libraries indicate that level of control would likely be desirable to authors. Some components provide mechanisms to customize the direction in which the popup is displayed in relation to the activating element. Literal positioning (top-center) and logical positioning (block-start-center) both seem relevant.

@chrishtr chrishtr changed the title [CSS-POSITION-4] Define a way to have a dialogue anchored to an element [CSS-POSITION-4] Define a way to have a dialog anchored to an element Apr 11, 2022
@ShanonJackson
Copy link

ShanonJackson commented May 23, 2022

I don't think the solution needs to introduce new syntax.

position absolute, top 100% puts you below your relative parent
position absolute top -100% puts you above your relative parent
position absolute left 100% puts you on the right of your relative parent
position absolute left -100% puts on the left of your relative parent

You can then use a combination of these with transform and calc to reach all desired positions without knowing the height/width of the relative parent ahead of time.

We just need to allow the dialog element itself to be positioned with css and then this should be enough to be able to achieve the desired outcome?

The true power of dialog is that it allows you to break overflow:hidden ancestors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants