Skip to content

Conversation

@chrisdavidmills
Copy link
Contributor

As discussed in mdn/content#40881, the browser support situation in our popover="hint" demo is not very clear. In browsers that don't support popover="hint", the tooltip behavior is not quite right. And in browsers that don't support CSS anchor positioning, the demo looks broken because the popovers don't appear as expected.

To mitigate these issues, I have updated the demo. Specifically, I have:

  • Added more details to the help paragraph about the support situation.
  • Moved the popovers inside the #wrapper <div> and given it a position of relative so that they should be positioned relative to the <div> rather than the <body> in non-supporting browsers (note: this still doesan't quite work property. Setting a fallback inset property still seems to position them relative to the <body>, and I'm not sure why)
  • Updated some of the other code relating to the button bar position to make the above possible.

I'm still not 100% happy with this, but the available information is a lot more useful now, and the demo looks less broken in non-supporitng browsers.

Once we've got this update merged, I'll then look at the associated MDN content and see if any of it needs updating as a result.

@chrisdavidmills chrisdavidmills requested a review from a team as a code owner August 28, 2025 09:46
@chrisdavidmills chrisdavidmills requested review from dipikabh and pepelsbey and removed request for a team August 28, 2025 09:46
Copy link
Member

@pepelsbey pepelsbey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry it took some time! A few suggestions for you to consider :)

margin: 0;
padding: 16px;
box-shadow: 1px 1px 3px #999;
z-index: -1;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line makes the paragraph unreachable to the cursor, as it’s hidden behind the body: no text selection, no link clicking.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, crap, that was foolish! In my next commit I have adjusted the z-index values to fix this issue.

Comment on lines 44 to 46
<div id="tooltip-1" class="tooltip" popover="hint">Tooltip A</div>
<div id="tooltip-2" class="tooltip" popover="hint">Tooltip B</div>
<div id="tooltip-3" class="tooltip" popover="hint">Tooltip C</div>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest putting tooltips right next to the buttons they’re triggered by. First of all, this is something you would most likely do in a real-world component to contain everything. Second, it might help to position them next to the buttons as a fallback for browsers that don’t support the hint value yet:

<button
  popovertarget="submenu-1"
  popovertargetaction="toggle"
  id="menu-1">
  Menu A
</button>

<div id="tooltip-1" class="tooltip" popover="hint">
  Tooltip A
</div>

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've done that, experimented with moving the HTML around a bit more besides, and made a few CSS adjustments, but I still can't make it work particularly well in browsers that don't support anchor positioning. Do you have any suggestions?

Comment on lines 13 to 38
<button
popovertarget="submenu-1"
popovertargetaction="toggle"
id="menu-1">
Menu A
</button>

<div id="tooltip-1" class="tooltip" popover="hint">Tooltip A</div>

<button
popovertarget="submenu-2"
popovertargetaction="toggle"
id="menu-2">
Menu B
</button>

<div id="tooltip-2" class="tooltip" popover="hint">Tooltip B</div>

<button
popovertarget="submenu-3"
popovertargetaction="toggle"
id="menu-3">
Menu C
</button>
</section>
</div>

<p class="help-para">
Press the buttons to show the auto popovers. Hover or focus the buttons to
show the hint popovers. When an auto popover is shown, you can show the
hint popovers without hiding it. See
<a
href="https://developer.mozilla.org/en-US/docs/Web/API/Popover_API/Using#using_hint_popover_state"
>Using "hint" popover state</a
>
for more information. Note that in non-supporting browsers, the position
of the popovers is broken.
</p>
<div id="tooltip-3" class="tooltip" popover="hint">Tooltip C</div>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you put the tooltips inside buttons, it falls back nicely!

Image
Suggested change
<div id="tooltip-3" class="tooltip" popover="hint">Tooltip C</div>
<button
popovertarget="submenu-1"
popovertargetaction="toggle"
id="menu-1">
Menu A
<div id="tooltip-1" class="tooltip" popover="hint">Tooltip A</div>
</button>
<button
popovertarget="submenu-2"
popovertargetaction="toggle"
id="menu-2">
Menu B
<div id="tooltip-2" class="tooltip" popover="hint">Tooltip B</div>
</button>
<button
popovertarget="submenu-3"
popovertargetaction="toggle"
id="menu-3">
Menu C
<div id="tooltip-3" class="tooltip" popover="hint">Tooltip C</div>
</button>

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you put the tooltips inside buttons, it falls back nicely!

Ah yes, the tooltips certainly sit more nicely. The menus are still a bit broken, but it is better than before.

@chrisdavidmills chrisdavidmills requested a review from a team as a code owner October 17, 2025 11:21
Copy link
Member

@pepelsbey pepelsbey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, thank you!

@chrisdavidmills chrisdavidmills merged commit ab2e70a into mdn:main Oct 17, 2025
1 check passed
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

Successfully merging this pull request may close these issues.

2 participants