News for hackers. Stuff that matters.
Re:Popover API by staminade on Friday May 10, 2024 @09:21AM (#40318645)
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]

[1] https://developer.chrome.com/blog/tether-elements-to-each-ot... [2] https://popper.js.org/docs/v2/

Re:Popover API by pupppet on Friday May 10, 2024 @10:43AM (#40319629)
Oh the number of hours CSS anchor positioning would’ve saved me over the years.
Re:Popover API by threatofrain on Friday May 10, 2024 @09:26AM (#40318706)
Re:Popover API by hanniabu on Friday May 10, 2024 @10:25AM (#40319419)
I'm amazed that in 2024 html/css doesn't have a tooltip attribute like there is for title
Re:Popover API by jimbobthrowawy on Friday May 10, 2024 @10:36AM (#40319548)
Does the "title" attribute not work? I tried adding one to the <span> containing your post and it worked. I assume that's non-standard.
Re:Popover API by codelikeawolf on Friday May 10, 2024 @10:43AM (#40319624)
The title attribute is not accessible, so its use is generally discouraged as an accessible label because screen readers can't pick it up (it's fine to use if you combine it with aria-label). Also, you can only show text in a title attribute, so the Popover API would allow you to add rich content to a tooltip (for better or worse :))

Edit: Remove extra "if"

Re:Popover API by Zecc on Friday May 10, 2024 @11:04AM (#40319878)
Why "can't" (won't) screen readers pick up the title attribute?
Re:Popover API by pickpuck on Friday May 10, 2024 @12:14PM (#40320664)
They do pick up the "title" attribute sometimes and apply it as a label. But it's not really the same as being able to keyboard navigate to the browser-generated tooltip.
Re:Popover API by dawnerd on Friday May 10, 2024 @11:16AM (#40320036)
Not just screen readers. Basically no support for anyone not using a mouse to navigate. Also really annoying when people put link text in a title on links.
Re:Popover API by uses on Friday May 10, 2024 @01:08PM (#40321343)
> The title attribute is not accessible

That's incorrect. There's nothing inherently inaccessible about the title attribute.

Voiceover, for example, reads the content of title attributes.

There are a bunch of reasons why title is pretty useless (the main one being it does nothing on every touch screen interface, where the concept of hover doesn't exist). But accessibility is not one of them.

Re:Popover API by codelikeawolf on Friday May 10, 2024 @03:48PM (#40323129)
> That's incorrect. There's nothing inherently inaccessible about the title attribute.

I think we might be splitting hairs here. There are accessibility concerns with the title attribute. MDN describes why the title attribute is problematic from an accessibility perspective [1] and provides a list of links with additional details. That MDN page also indicates that the title attribute is problematic for:

- People using touch-only devices

- People navigating with keyboards

- People navigating with assistive technology such as screen readers or magnifiers

- People experiencing fine motor control impairment

- People with cognitive concerns

That's a non-trivial amount of web users. So is it technically accessible? Yes. But if you want to deliver an accessible experience to everyone, and the title attribute is going to cause issues, I personally would define that as not being accessible.

[1] https://developer.mozilla.org/en-US/docs/Web/HTML/Global_att...

Edit: Formatting

Re:Popover API by wruza on Friday May 10, 2024 @03:06PM (#40322729)
Re:Popover API by tshaddox on Friday May 10, 2024 @10:46AM (#40319675)
It takes ages to show up when you’re hovering on something.
Re:Popover API by hanniabu on Sunday May 12, 2024 @03:17PM (#40336780)
The title attribute has poor discoverability since you need to long-tap/hover to see it. Need something that shows instantly.

The title attribute disappears once you move the mouse off the object vs clicking to keep it open or having a delay on it.

You also can't have html in a title attribute.

Re:Popover API by jcutrell on Friday May 10, 2024 @09:25AM (#40318693)
How is anchor different from relative?
Re:Popover API by staminade on Friday May 10, 2024 @09:34AM (#40318785)
The article I linked goes into the details, but basically a relative approach constrains your markup: The positioned thing must be a child of the relatively positioned anchor or a wrapper element, and you often cannot sensibly position it without using JS to check the location of the anchor. E.g. a popover menu for a button must check if the button is close to an edge of the viewport and position the menu element appropriately. Anchor positioning will do this automatically.

Also, if support for multiple anchors is included, then it opens up some very interesting capabilities to do things like draw arbitrary diagram connectors between elements: https://kizu.dev/anchor-positioning-experiments/

Re:Popover API by karaterobot on Friday May 10, 2024 @06:31PM (#40324382)
I've been eagerly awaiting anchor positioning, but using it for diagram connectors had not occurred to me yet! That would solve so many problems that I currently have (or plan) to use D3 for.
Re:Popover API by CuriouslyC on Friday May 10, 2024 @09:27AM (#40318715)
They explain in the first couple paragraphs of the first link provided.
Re:Popover API by paavohtl on Friday May 10, 2024 @09:33AM (#40318776)
position: relative adds a fixed offset to the position the element would have been placed in normally, but position: anchor can be used to place an element near any arbitrary element, regardless of its place in the DOM hierarchy.
Re:Popover API by ndom91 on Friday May 10, 2024 @12:50PM (#40321129)
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!

Re:Popover API by Fatnino on Friday May 10, 2024 @02:51PM (#40322550)
Aren't there only 2 browsers? There is Firefox and there are all the Chrome derivatives.
Re:Popover API by hoistbypetard on Friday May 10, 2024 @03:35PM (#40323011)
Safari and Mobile Safari are common and are neither Firefox nor Chrome derivatives.

Uncommon and neither Firefox nor Chrome Derivatives: Netsurf, Dillo, Ladybird each have their own engines. A few browsers also use a Gecko fork called Goanna. (Pale Moon comes to mind first, but there are at least a couple others that use the same engine.) Then there's Konqueror. It's not common, but can either use old KHTML or WebKit (Safari's engine).

Re:Popover API by oidar on Friday May 10, 2024 @05:55PM (#40324149)
Also: Orion uses Webkit on macs. Development is cruising along.
Re:Popover API by unakrav on Friday May 10, 2024 @02:20PM (#40322169)
I just shipped a new article all about how to use the CSS anchoring API, which is landing in Chromium next week! https://developer.chrome.com/blog/anchor-positioning-api
Re:Popover API by mardifoufs on Friday May 10, 2024 @03:05PM (#40322716)
I love articles with actual running examples, thanks! Now I'm wondering how quickly this will get adopted, it looks very cool!
Re:Popover API by swyx on Friday May 10, 2024 @05:10PM (#40323833)
whats a reasonable expectation for this to get adopted across safari/firefox/edge? 1yr? 3yrs?
Re:Popover API by chrishtr on Friday May 10, 2024 @06:31PM (#40324380)
Re:Popover API by hkdobrev on Friday May 10, 2024 @06:01PM (#40324200)
The source link at the top of the article leads to a 404.
Re:Popover API by oddgoo on Thursday May 16, 2024 @07:42AM (#40377167)
Fantastically illustrated and interactive article! I wonder if/how Tailwind will grow to adapt this, as I'm pretty happy with their abstractions now.