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

Popover position improvement idea #29868

Open
ellatrix opened this issue Mar 15, 2021 · 2 comments
Open

Popover position improvement idea #29868

ellatrix opened this issue Mar 15, 2021 · 2 comments
Labels
[Feature] Component System WordPress component system [Type] Discussion For issues that are high-level and not yet ready to implement.

Comments

@ellatrix
Copy link
Member

Alternative to the idea proposed in #21275.

The popover position API is very clunky and it tries to satisfy a lot of different positioning needs.

What if we provide a base rectangle and allow popovers to be positioned from there, purely in CSS? Why reinvent the wheel and maintain or introduce a positioning API if CSS provides a great one?

How could this be done?

Instead of positioning a popover immediately at the target position, we position the wrapper popover div element exactly over the anchor element so that it has the same dimensions and positions (base rectangle).

Screenshot 2021-03-15 at 13 15 08

^= Imagine a the popover div overlays the anchor div.

From there, the popover content div can take any relative position it wants through the CSS positioning API. You can even stretch it as an overlay (imagine a block overlay through a popover).

That's pretty much it. :)

Of course we can map the existing position API with CSS, and we can provide better JS shortcuts if we want. The point is for it to be powered by CSS under the hood and allow all the flexibility of CSS.

Cc @youknowriad.

@ellatrix ellatrix added the [Type] Discussion For issues that are high-level and not yet ready to implement. label Mar 15, 2021
@youknowriad
Copy link
Contributor

I think a good position API would be good, I think in the ideal world, we'd compose UI components without writing any bit of CSS. That said, the current position API is definitely bad and also, this doesn't prevent us from actually basing the implementation of the Popover component the way you suggest above. (I'd also like a prop to not do anything aside cover the anchor) :P

Also cc @sarayourfriend @ItsJonQ since they integrated a new Popover component on the code base that needs to be brought in sync with the current one as well.

@ellatrix
Copy link
Member Author

Right, it doesn't prevent us from making an API in JS that is powered by CSS under the hood. We can still use props as shortcuts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Component System WordPress component system [Type] Discussion For issues that are high-level and not yet ready to implement.
Projects
None yet
Development

No branches or pull requests

3 participants