Skip to content

fix(Popover): in a Picture-in-Picture window, it scrolls once its window is too short - #9098

Merged
cixzhang merged 1 commit into
meta:mainfrom
vjeux:popover-own-window-overflow
Oct 31, 2026
Merged

cixzhang merged 1 commit into
meta:mainfrom
vjeux:popover-own-window-overflow

Conversation

@vjeux

@vjeux vjeux commented Oct 31, 2026

Copy link
Copy Markdown
Contributor

User impact

When an app renders a Popover into 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 ResizeObserver on the surface, mutations and resource loads. The listeners and the ResizeObserver came from the page's window:

  • a Picture-in-Picture window's resize fires only in that window;
  • a ResizeObserver the page created checks a box in another window only while the page renders frames, so with the page idle nothing measures again;
  • the surface's maximum height follows its own window, so it shrinks but never scrolls.

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 its ResizeObserver, 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

  • Before (main 0bdda32, Chromium 149, the page hidden and idle, the window really resized to 206 px): the surface is 174 px tall for 260 px of content, overflow-y visible.
  • After: overflow-y auto, and it stops scrolling once the window is tall again.
  • Unchanged: the page and iframe cases pass before and after. A page that is drawing frames hides the bug on main.
  • Regression tests: the new Vitest case and the two Picture-in-Picture spec cases fail on main and pass with the fix.

Scope

  • One defect is restored.
  • Separable contradictory or unsettled tagalongs were removed or split.
  • No new public API, visual representation, default, or interaction model is hidden under the bug-fix label.
  • Public text and artifacts contain no internal Meta context.

Testing

How to check:

  1. In Chrome, open the story "a11y/Popover in a second document" and select Pop out.
  2. Make the Picture-in-Picture window taller than the Long list, then open Long list in it.
  3. Make the window shorter than the list. Before: the list is cut off and does not scroll. After: it scrolls.

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:

  • Popover and Layer suites: 331 passed, including the new iframe case, which fails on main.
  • PopoverSecondDocument.a11y.chromium.spec.ts in Chromium: 23 passed. The two new Picture-in-Picture cases fail on main, and the page and iframe cases pass on both.
  • Core typecheck, ESLint with no warnings, Prettier, pnpm check:repo and the Storybook build.
  • pnpm test:ui and pnpm test:node: the same failures as on main, none in Popover.

…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.
@vercel

vercel Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
astryx Ready Ready Preview Oct 31, 2026 3:05am UTC

Request Review

@astracat-bot

astracat-bot Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Oct 31, 2026, 3:13 AM UTC

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Oct 31, 2026
@github-actions

github-actions Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR

🧪 Sandbox Preview

View Sandbox for this PR

Modified Components

Popover (@astryxdesign/core) · View in Storybook
Metric Before After Delta
Entry File (ESM) 412B 412B 0B
Lines of Code 977 986 -
Complexity Very High Very High (147) -

Component Size

Component Import before Import after Delta CSS before CSS after Delta
core/Popover 51.1KB 51.1KB +46B 12.2KB 12.2KB 0B
lab/ChatEmojiPicker N/A 67.0KB N/A N/A 773B N/A
lab/ChatReactionBar N/A 67.6KB N/A N/A 1.1KB N/A
lab/CommentComposer N/A 95.8KB N/A N/A 1.9KB N/A
lab/CommentThread N/A 218.4KB N/A N/A 2.4KB N/A
lab/Comments N/A 222.9KB N/A N/A 2.5KB N/A
lab/TourStep N/A 56.5KB N/A N/A 590B N/A

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 Summary

Gzip figures measure each package's entry file, not the code an import pulls in.

Package Entry (ESM) Entry gzip before Entry gzip after Delta
@astryxdesign/core 4.9KB 1.2KB 1.2KB 0B
Package stylesheet Gzip before Gzip after Delta
@astryxdesign/core 35.6KB 35.6KB 0B

Accessibility Audit

Status: The accessibility audit did not run on this pull request. It runs after merges to main and before each release; pull requests that touch components run it with the ci:heavy-lanes label.


Generated by PR Enrichment workflow | Storybook | Sandbox | View full report

@astracat-bot astracat-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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]

@cixzhang cixzhang added the ci:run A maintainer lets this outside contributor's pull request run CI (AST-030 FR17) label Oct 31, 2026
@cixzhang
cixzhang marked this pull request as ready for review October 31, 2026 04:04
@cixzhang
cixzhang merged commit f233ad6 into meta:main Oct 31, 2026
99 checks passed
@vjeux
vjeux deleted the popover-own-window-overflow branch October 31, 2026 05:07

This branch was successfully deployed

1 active deployment
Preview — b1188e75 Deployed Oct 31, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:run A maintainer lets this outside contributor's pull request run CI (AST-030 FR17) CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants