Repository navigation
fix(Popover): in a Picture-in-Picture window, it scrolls once its window is too short - #9098
Conversation
…dow is too short A Popover rendered into a Document Picture-in-Picture window measured its overflow through the page's window: the page's resize events, the page's animation frames, and a ResizeObserver the page created. The Picture-in-Picture window's own resize never reached it, and the page's ResizeObserver only checks sizes while the page renders frames. With the page idle, a window too short for the popover, or content that grew past it, left the popover cut off with no scrollbar. The overflow measurement now observes from the window the popover renders in: its resize and visual-viewport events, its ResizeObserver and its animation frames. In the page that window is the page's own, so nothing changes there.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
PR Analysis Report📚 Storybook Preview🧪 Sandbox PreviewModified ComponentsPopover (@astryxdesign/core) · View in Storybook
Component Size
Sizes are gzip. Import counts the JavaScript the import loads eagerly; CSS counts the package stylesheet rules referenced by the modules it can load from its own package, lazily loaded ones included. Bundle Size SummaryGzip figures measure each package's entry file, not the code an import pulls in.
Accessibility AuditStatus: The accessibility audit did not run on this pull request. It runs after merges to Generated by PR Enrichment workflow | Storybook | Sandbox | View full report |
There was a problem hiding this comment.
This fix looks ready to approve. Popover now measures its overflow from the window it renders in, which restores scrolling in a Document Picture-in-Picture window and leaves the page case unchanged. In a browser check of the story's Long list, the list was cut off and could not scroll in a short Picture-in-Picture window before the change, and scrolled to its last row after it; content that grows behaves the same way. The new Vitest case fails without the fix and passes with it, so nothing more is needed beyond the usual CI run once the pull request leaves draft.
[Automated review]
User impact
When an app renders a
Popoverinto a Document Picture-in-Picture window, the popover stops scrolling there. If that window gets shorter than the popover, or its content grows, it is cut off with no scrollbar. In the story's Long list, a 206 px window cut the 260 px list to 174 px, leaving 86 px out of reach of pointer, wheel and keyboard. In the page and in an iframe, it scrolls.We hit this moving one app onto Astryx. #7356 fixed focus, Tab and Escape there, but the overflow measurement still read the page's window.
Problem and solution fit
Popover measures overflow again on window resize, visual-viewport resize, a
ResizeObserveron the surface, mutations and resource loads. The listeners and theResizeObservercame from the page's window:ResizeObserverthe page created checks a box in another window only while the page renders frames, so with the page idle nothing measures again;Expected behavior and authority
component:Popover(current), FR4: "Popover enables internal scrolling only after measured overflow exceeds the current tolerance". PR1 covers its resize observation. Both hold in any window, so neither changes.Smallest restoration
The overflow measurement takes the surface's own window, its document's
defaultView, for itsResizeObserver, its resize and visual-viewport listeners and its animation frame. In the page, that window is the page's, so nothing changes. Focus, Tab containment, dismissal and the mutation observer are untouched. The story gains a Long list popover in each document.Not chosen: only the window listener, since growing content would still go unseen; or a maximum height computed in JavaScript, which duplicates the CSS viewport fit.
Evidence
visible.auto, and it stops scrolling once the window is tall again.Scope
Testing
How to check:
The unit test uses an iframe's window because jsdom has no Picture-in-Picture window. It checks that the measurement listens on the surface's own window. In a real browser an iframe is still covered, because it renders with the page, as the spec's iframe cases show.
Local gates at b1188e7:
PopoverSecondDocument.a11y.chromium.spec.tsin Chromium: 23 passed. The two new Picture-in-Picture cases fail on main, and the page and iframe cases pass on both.pnpm check:repoand the Storybook build.pnpm test:uiandpnpm test:node: the same failures as on main, none in Popover.