I think the Popover API will be really transformative when CSS Anchor Positioning[1] arrives as well. Anchor positioning will let you position elements relative to others on the page. Combined with the Popover API it will let you implement things like custom tooltips and context menus in a declarative way and without any need for libraries like PopperJS [2]
This is the critical missing piece. Tried playing with and ship something with the new popover API last week, but missing positioning support in all browsers is really holding this back from more use-cases.
Looks like the last browser (FF) has already shipped anchor positioning in beta, so it won't be long!
And also <details> if you need expanding/collapsing content, or, with a slight abuse, a "dropdown".
Strange that unlike <dialog open> and <details open>, `<whatever popover>` apparently lacks the the ability to be made declaratively `open` using the attribute. This feels like omission to me. I hope there is some based reasoning behind this decision.
I'd warn that there's a fair bit of work you have to do to get animations and typical modal behavior working up to the level of modern day expectations. It's completely surmountable but also quite non-trivial.
I absolutely see the need for this if implemented in concert with the host OS windowing system, because current popovers must be emulated in a way that does not always work well.
For example, a browser-native <select> today will be able to expand beyond the borders of the hosting browser window, so you can don't have to worry about it getting clipped to the window borders, but a fancy emulated select from toolkit like Quasar will not, ,which limits its placement options. So to do this right on win32 you would need each popover to have its own native HWND and on Cocoa/macOS you would need it in its own NSView.
Does anybody in here know if this is how it is actually implemented in the current browsers, or is it just a paint-over job inside the browser window?
These popovers are just regular DOM nodes styled with regular CSS.
Giving websites a vector to paint outside the designated viewport (except in extremely limited circumstances like alert(), confirm(), [title], <select>, etc.) makes it a lot easier for them to convincingly emulate browser and OS dialogs. It's a massive security risk, I don't think it's worth the limited upside. Concrete example: a page emulating your password manager extension's unlock widget.
Edit: Note that this is not a theoretical concern. Scammers over the years have created extremely convincing fake UI elements, including fake popup windows complete with the browser chrome. They're even draggable. Not being to paint past the viewport boundary is one of very few, if not the only limitation they couldn't get around.
How useful is such a feature in reality? On smaller devices, the web brower almost always covers the whole screen, and even on big monitors, it usually touches at least one corner.
It will also make it semantically easier to detect. I'm thinking about accessibility and crawlability but also in case anyone wants to write some "no popup" plugin.
Firefox, for one, technically supports "popping out" part of a page's content into a separate OS-level window. It exposes that functionality through the XUL <panel> and <menupopup> elements, which are only available to privileged [X]HTML being rendered in the browser's main process. I doubt that any browser developer would want to give ordinary web pages the ability to create borderless OS windows.
I don’t see web apps getting the native windowing system integration you envision anytime soon. The fact that some standard controls behave that way is an OS-specific implementation side effect of them being implemented as OS-native, which they aren’t required to be.
I get the gist of what you're saying, but I don't think they're really comparable. Popups spam your OS with trash that impairs your ability to use your machine (at worst). Popover dialogs can be shut down by closing your tab and nothing more. We've also had these style of popovers for a while now because they're generally a really handy way of presenting info. Yeah, they can be used in annoying ways, but there are lots of genuine usecases, like a modal.
All this means is that you can implement popovers without having to include a magic extra library. All blocking an explicit "popover" element would do is cause people to stick with custom libraries.
This is not a pop-up. People hate popups because they're intrusive and have their own window. This API replaces div modals and saves time and code for developers.
It also helps that we now just have spam covering content and slowing our computer down inside the window. Hell, many publications will even get you to pay for the privilege.
> Popovers created using the Popover API are always non-modal. If you want to create a modal popover, a <dialog> element is the right way to go.
Why? This is a legitimate use case for a popover. Especially if you're blurring the background while it's open. Why even offer that feature if a user's click can potentially trigger an action on some blurred out button.
*edit:
Apparently, you can combine the two:
> You can turn a <dialog> element into a popover (<dialog popover> is perfectly valid) if you want to combine popover control with dialog semantics.
Wouldn't <popover modal=true> make more sense here? They're clearly acknowledging a use case.
Very cool. So if I understand correctly, this doesn’t really introduce any new capability, it just streamlines the need to have a modal div, mask div, container div, and some uncomfortable positioning CSS? It also adds some pseudo classes to simplify styling. I like it.
It also allows for the basic functionality without JS (and without overloading a hidden checkbox). I'm not sure how far that will get you so maybe JS will be needed for a styled and animated popover, but no-JS support with focus handled properly is nice.
I want to say there was also accessibility support built in but now I don't see it in the spec. If it handles announcing the elements to accessibility tools like a screen reader that'll really help too, its pretty easy to forget to do it manually.
And in the nested popovers demo you can't go diagonally from Pizza to Ham, cause nobody in chrome or firefox bothered to implement a delay before a submenu disappears. Decades of UX research lost, almost as expected.
The docs warn that there is no role associated with the popover attribute because it could be a menu, tooltip, etc., and you should put the correct role on it. Accessibility-wise it does take care of the item with the popovertarget, so you don't have to put aria-controls and aria-expanded.
We already have infinite popover js/css libraries so this doesn't solve any unsolved problem. I suspect this will be like select, where you almost always want some functionality or styling that can't be done natively so you reach for a custom solution or use some existing library.
Maybe if I start a new app this is OK as a stopgap until I need more functionality (which always happens), but in my existing app I'm just using the already existing popover library for consistency
I suspect this isn't going to get major usage. Making it a dedicated API makes these things easier to target by extensions and thus easier to block. There are legitimate usages but almost all of the ones I encounter are marketing call to actions and invasive support chat boxes which are both almost universally hated and would the target of those blocking action.
in terms of accessibility, i imagine a universal standard for modal state management will be an improvement over the bespoke approach - closing when the user presses escape, focus handling, etc.
but i really wish popover=hint made it into the spec. would have been nice to get a native alternative to tippy.js
Another extremely useful feature that won’t work for our Safari users with any older than 1 year old iPhones and means for the next five years we have to support both this API and a full-blown polyfill or alternative implementation.
It's a shame that browser developers have to implement enough of this API to entice people to use it, only for users to install extensions that simply disable it ;)
[+] [-] staminade|1 year ago|reply
[1] https://developer.chrome.com/blog/tether-elements-to-each-ot... [2] https://popper.js.org/docs/v2/
[+] [-] unakrav|1 year ago|reply
[+] [-] threatofrain|1 year ago|reply
https://caniuse.com/css-anchor-positioning
[+] [-] pupppet|1 year ago|reply
[+] [-] ndom91|1 year ago|reply
Looks like the last browser (FF) has already shipped anchor positioning in beta, so it won't be long!
[+] [-] hanniabu|1 year ago|reply
[+] [-] unknown|1 year ago|reply
[deleted]
[+] [-] jcutrell|1 year ago|reply
[+] [-] eknkc|1 year ago|reply
[+] [-] myfonj|1 year ago|reply
Strange that unlike <dialog open> and <details open>, `<whatever popover>` apparently lacks the the ability to be made declaratively `open` using the attribute. This feels like omission to me. I hope there is some based reasoning behind this decision.
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/de...
[+] [-] threatofrain|1 year ago|reply
[+] [-] jacobgorm|1 year ago|reply
For example, a browser-native <select> today will be able to expand beyond the borders of the hosting browser window, so you can don't have to worry about it getting clipped to the window borders, but a fancy emulated select from toolkit like Quasar will not, ,which limits its placement options. So to do this right on win32 you would need each popover to have its own native HWND and on Cocoa/macOS you would need it in its own NSView.
Does anybody in here know if this is how it is actually implemented in the current browsers, or is it just a paint-over job inside the browser window?
[+] [-] oefrha|1 year ago|reply
Giving websites a vector to paint outside the designated viewport (except in extremely limited circumstances like alert(), confirm(), [title], <select>, etc.) makes it a lot easier for them to convincingly emulate browser and OS dialogs. It's a massive security risk, I don't think it's worth the limited upside. Concrete example: a page emulating your password manager extension's unlock widget.
Edit: Note that this is not a theoretical concern. Scammers over the years have created extremely convincing fake UI elements, including fake popup windows complete with the browser chrome. They're even draggable. Not being to paint past the viewport boundary is one of very few, if not the only limitation they couldn't get around.
[+] [-] Silphendio|1 year ago|reply
[+] [-] tootie|1 year ago|reply
[+] [-] rafram|1 year ago|reply
[+] [-] unknown|1 year ago|reply
[deleted]
[+] [-] layer8|1 year ago|reply
[+] [-] sseagull|1 year ago|reply
I’m old enough to remember the pop-up and pop-under wars of the late 90s and early 2000s.
I guess we won that particular battle, but the war for our attention is far from over.
[+] [-] bestest|1 year ago|reply
A popover is floating element that appears to display a contextual piece of information when required.
What you're mentioning is something completely different.
[+] [-] jjice|1 year ago|reply
[+] [-] gwd|1 year ago|reply
https://getbootstrap.com/docs/5.3/components/popovers/
All this means is that you can implement popovers without having to include a magic extra library. All blocking an explicit "popover" element would do is cause people to stick with custom libraries.
[+] [-] 1231232131231|1 year ago|reply
[+] [-] gyomu|1 year ago|reply
You don’t want that boundary to be broken, because that makes for less usable and less safe systems.
[+] [-] darby_eight|1 year ago|reply
[+] [-] efilife|1 year ago|reply
[+] [-] H1Supreme|1 year ago|reply
Why? This is a legitimate use case for a popover. Especially if you're blurring the background while it's open. Why even offer that feature if a user's click can potentially trigger an action on some blurred out button.
*edit:
Apparently, you can combine the two:
> You can turn a <dialog> element into a popover (<dialog popover> is perfectly valid) if you want to combine popover control with dialog semantics.
Wouldn't <popover modal=true> make more sense here? They're clearly acknowledging a use case.
[+] [-] eyelidlessness|1 year ago|reply
[+] [-] Waterluvian|1 year ago|reply
[+] [-] _heimdall|1 year ago|reply
I want to say there was also accessibility support built in but now I don't see it in the spec. If it handles announcing the elements to accessibility tools like a screen reader that'll really help too, its pretty easy to forget to do it manually.
[+] [-] devmor|1 year ago|reply
That is definitely useful.
[+] [-] Alifatisk|1 year ago|reply
[+] [-] wruza|1 year ago|reply
https://mdn.github.io/dom-examples/popover-api/nested-popove...
[+] [-] nikkwong|1 year ago|reply
[+] [-] niek_pas|1 year ago|reply
[+] [-] charlesabarnes|1 year ago|reply
[+] [-] simonw|1 year ago|reply
[+] [-] mdev23|1 year ago|reply
[+] [-] kitallis|1 year ago|reply
Here's a custom implementation with Stimulus using Popper – https://github.com/tramlinehq/tramline/blob/main/app/javascr...
And here's one for <dialog> – https://github.com/tramlinehq/tramline/blob/main/app/javascr...
[+] [-] silverwind|1 year ago|reply
[+] [-] megaman821|1 year ago|reply
[+] [-] suyash|1 year ago|reply
1. Pop up menu like those on Windows/Ubuntu : https://mdn.github.io/dom-examples/popover-api/nested-popove...
2. Android style toast notifications: https://mdn.github.io/dom-examples/popover-api/toast-popover...
[+] [-] ativzzz|1 year ago|reply
We already have infinite popover js/css libraries so this doesn't solve any unsolved problem. I suspect this will be like select, where you almost always want some functionality or styling that can't be done natively so you reach for a custom solution or use some existing library.
Maybe if I start a new app this is OK as a stopgap until I need more functionality (which always happens), but in my existing app I'm just using the already existing popover library for consistency
[+] [-] delichon|1 year ago|reply
https://kagi.com/proxy/passover-popovers-6.jpg?c=gBnCtLe1QYl...
No you can't have that word to mean something else, it's sacred. And because you tried you can't have any of my popovers either.
[+] [-] TrueDuality|1 year ago|reply
[+] [-] ikesau|1 year ago|reply
but i really wish popover=hint made it into the spec. would have been nice to get a native alternative to tippy.js
[+] [-] globalise83|1 year ago|reply
[+] [-] tijssss|1 year ago|reply
[+] [-] seltzered_|1 year ago|reply
Allowed a nice way to float a list with content for users to copy.
[+] [-] jrockway|1 year ago|reply