Skip to content

Place a popover again when its content changes size - #2878

Merged
manilabui merged 1 commit into
Foundry376:masterfrom
brhellman:fixed-popover-refit
Sep 18, 2026
Merged

manilabui merged 1 commit into
Foundry376:masterfrom
brhellman:fixed-popover-refit

Conversation

@brhellman

Copy link
Copy Markdown
Contributor

The follow-up from #2874: with the card and editor scrolling inside the window, the editor's footer could still sit below it. PopoverStore renders one FixedPopover per open, and the card becomes the editor through CalendarEventPopover's own state, so nothing on FixedPopover changed and it never measured the taller box. The editor stayed centred where the card had been, and with the anchor low in the window its Save row ran past the bottom.

FixedPopover now observes its own size with a ResizeObserver and, once the content changes size after placement, restarts placement from the requested direction, flipping, nudging and clamping as opening at the new size would. The observer's first callback and the placement passes themselves are ignored through a placing flag, so the re-placement runs once per size change rather than looping. The card shrinking back to its size on Cancel takes the same path.

Verification

Static, on this exact commit: lint:check 0, typecheck 0, full suite 1885 passing locally and on fork CI: run 35296344907, green.

Spec: a 100px child anchored at y=400 in a 500px window is placed beside its anchor; grown to 2000px, the popover is placed again and its top comes back inside the window. The spec drives the inner FixedPopover the AutoFocuses decorator renders, since that is where placement state and refs live; placement passes run on the mocked clock and the resize step is awaited through the real observer. Mutation: with the observe call removed, the spec times out waiting for the size change to be observed and nothing else fails.

Live A/B on a real account (same config copy, task queue and recurring dialog stubbed), opening the card for the same recurring event with invitees and clicking its edit icon with real mouse input; the viewport height is set with the page zoom factor so both builds are measured at the same CSS height:

viewport height master 09eb665cc: editor bottom, Save this commit: editor bottom, Save
844 / 848 924, Save 894-919, elementFromPoint at its centre null 838, Save 808-832, hit-test the Save button
659 / 661 720, Save 690-715, null 657, Save 628-652, the Save button

On master the card itself fit in both cases (bottom 836 and 649); only the editor it turned into did not.

🤖 Generated with Claude Code

The event card becomes the editor in place, through the card's own state, so FixedPopover never
measured the taller box: it stayed centred where the card had been and its footer ran past the
bottom of the window. A ResizeObserver on the popover now restarts placement from the requested
direction, as opening at the new size would.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@manilabui

Copy link
Copy Markdown
Contributor

Looks good to me. Thanks!

@manilabui
manilabui merged commit 089d6ab into Foundry376:master Sep 18, 2026
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