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

[Popup] Position via HTML attribute rather than CSS property #458

Closed
chrishtr opened this issue Feb 13, 2021 · 3 comments
Closed

[Popup] Position via HTML attribute rather than CSS property #458

chrishtr opened this issue Feb 13, 2021 · 3 comments
Assignees

Comments

@chrishtr
Copy link

I think that rather than specifying a new CSS property or value to indicate the origin of the position for a popup, it should/could be done with an HTML attribute, something like:

<popup for=#myElement>

This would mean that the popup element positions relative to the top-left logical edge #myElement when open. If needed, additional syntax could be added to indicate a center- or right-aligned origin point as well.

The advantage of doing this is that it allows the User Agent to stop positioning it in that way as soon as the popup is dismissed. It is desirable for the User Agent to do that because otherwise all of the complex scrolling and compositing paths will have to be augmented so as to keep the popup positioned relative to the element.

With the HTML attribute, the User Agent can dismiss the popup under all of the situations when complex things would otherwise happen, such as threaded scrolling or animation changes.

I suggested for= based on the TAG review feedback from Lea Verou.

@melanierichards
Copy link
Contributor

melanierichards commented Feb 17, 2021

Reusing the for attribute instead of introducing an anchor attribute could be reasonable. I think the right design depends somewhat on how we resolve declarative invocation, because ostensibly the for attribute would be the best fit for the invoker/invokee relationship. Oftentimes the element that invokes the popup and the element that the popup should be anchored to are one in the same, but that's not necessarily always true. For example, teaching UI popups should be anchored to the element they describe, which may be an interactive element. That interactive element when invoked should not show/hide the popup, it should perform some other action.

This would mean that the popup element positions relative to the top-left logical edge #myElement when open. If needed, additional syntax could be added to indicate a center- or right-aligned origin point as well.

The advantage of doing this is that it allows the User Agent to stop positioning it in that way as soon as the popup is dismissed. It is desirable for the User Agent to do that because otherwise all of the complex scrolling and compositing paths will have to be augmented so as to keep the popup positioned relative to the element.

Are these benefits moot if the additional syntax is expressed in CSS rather than in HTML?

cc @mfreed7 @BoCupp-Microsoft

@chrishtr
Copy link
Author

Are these benefits moot if the additional syntax is expressed in CSS rather than in HTML?

Yes. This is why I don't think it's a good idea to specify anchored positioning in CSS. I have put down some more thoughts here.

@melanierichards
Copy link
Contributor

I think I'll close this issue for now, and we can revisit once the anchor pos proposal is up.

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

No branches or pull requests

4 participants