Use a Popover component for the share annotation floating "bubble" - #7159
Conversation
ac5ca91 to
4200071
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #7159 +/- ##
==========================================
- Coverage 99.45% 99.45% -0.01%
==========================================
Files 270 270
Lines 10958 10955 -3
Branches 2623 2621 -2
==========================================
- Hits 10898 10895 -3
Misses 60 60 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
4200071 to
3d5ee9b
Compare
23d3161 to
f5beeaf
Compare
| const toggleSharePanel = () => setOpen(!isOpen); | ||
| const closePanel = () => setOpen(false); | ||
|
|
||
| usePopoverShouldClose(shareRef, closePanel, { enabled: isOpen }); |
There was a problem hiding this comment.
This is not needed anymore. Everything it does is handled by the Popover component internally.
8f54d92 to
a7240d5
Compare
a7240d5 to
f61e2ee
Compare
Setting |
Good catch. This is because of the changes I did here https://github.com/hypothesis/frontend-shared/pull/2011/files#diff-812511814bb9e545b0977fdf9aac8521d21ec33f5087d9cf4e4f5c518e6b16a1L381-L384 I have found other issue also caused by those changes hypothesis/frontend-shared#2013 |
|
I'm going to put this back in draft, as the latest frontend-shared version has a couple regressions in the popover. I'll get back to this once those are fixed. |
f61e2ee to
b92f5f8
Compare
|
Putting this back as ready to review now that Popover regressions are fixed. |
|
I found an issue that the Popover styling is broken when the browser doesn't support native popovers, tested via
Unfortunately native popovers are still a little too new for us to rely on them being always available. |
robertknight
left a comment
There was a problem hiding this comment.
Apart from the issue with non-native popovers, this looks good. I noted that there is a workaround for copy-to-clipboard which is no longer needed and can be removed.
b92f5f8 to
2476e66
Compare
| // Set explicit width for browsers not supporting native popover API | ||
| 'w-[360px] max-w-[calc(100vw-3.5rem)]': | ||
| // eslint-disable-next-line no-prototype-builtins | ||
| !HTMLElement.prototype.hasOwnProperty('popover'), |
There was a problem hiding this comment.
When the Popover API is not supported by the browser, it ends up being too narrow. These classes work around it.
non-native-popover-2025-06-19_14.35.27.mp4
See #7159 (comment) for details
There was a problem hiding this comment.
Where does the width come from when the native popup API is supported?
There was a problem hiding this comment.
Why do we use different values for native and non-native popovers? This inconsistency seems liable to trip us up elsewhere in future.
There was a problem hiding this comment.
It's hard to say at this point, as implementing the Select, and then extracting the Popover, required many rounds, and it's possible I overlooked something. It's even likely these classes were required to make it look consistent for that specific use case.
The main difference is that, since the native popover renders in the top layer, relative widths are hard to normalize for both native and non-native popovers, which end up looking different depending on their containers.
There was a problem hiding this comment.
The main difference is that, since the native popover renders in the top layer, relative widths are hard to normalize for both native and non-native popovers, which end up looking different depending on their containers.
The current max width for native popovers is expressed in terms of viewport units, so I would have thought it would work the same for native and non-native popovers.
Edit: No sorry, I misread this. It is expressed in terms of the parent width. I presume that "100%" are referring to different things for native and non-native popovers. If we used "100vw" instead, that would work the same in both cases.
There was a problem hiding this comment.
If we used "100vw" instead, that would work the same in both cases.
That may very well be the case. I can explore this option.
2476e66 to
c10df18
Compare
robertknight
left a comment
There was a problem hiding this comment.
I suggested a small change to set the width using w-max. Otherwise I think we should get this merged. Ideally we could improve Popover in future to minimize behavioral differences.
c10df18 to
ad2ef1a
Compare





Depends on #7160
Depends on hypothesis/frontend-shared#2000
Depends on hypothesis/frontend-shared#2011
The share annotation "bubble" is currently an absolute-positioned Card. This PR replaces that with a
Popover.popover-arrow-sidebar-2025-06-17_15.43.14.mp4
Some issues found:
Popover is displayed underneath the anchor when there's space. We would like to change that behavior.Addressed in Allow to customize initial Popover placement frontend-shared#2000The arrow is not rendered, because the dynamic positioning of the Popover would require the anchor position to be calculated in real time.Addressed in Allow an arrow to be added to popover component frontend-shared#2011