fix(calendar): keep the quick-create popover inside the window - #971
Merged
Conversation
The week grid is an infinitely virtualized day strip: its own element is ~4.5M px wide and, once scrolled to today, its left edge sits ~2.6M px outside the window. Two places trusted that rect. buildSelection fell back to the strip's left edge whenever the day column element could not be measured, so the marquee anchor landed millions of pixels off-viewport while its y stayed correct. computePopoverPosition then trusted that anchor with no clamp on the far edge, parking the quick-create popover outside the window — visible, enabled, and permanently unclickable. Offset the fallback anchor by the column index (day view has a single column at index 0, so it is unchanged) and clamp the popover into the viewport so no anchor can push its Save row out of reach. The clamp covers every caller: task, note, event, inbox-snooze and quick-create.
|
React Doctor found no new issues. 🎉 Reviewed by React Doctor for commit |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Desktop CI "Electron E2E full (3/16)" has been red on main with one failing test:
apps/desktop/tests/e2e/calendar-marquee.e2e.ts:100— drag + Save-button click creates event (week view) — regressionNot the old "submit button disables itself mid-click" defect — that fix (
onPointerDown) is still in place and still works. This one is placement: the popover is rendered outside the window, soSavecan never be clicked. That is a product bug, not a test bug: any user in that state cannot reach Save either.Root cause
The week grid is an infinitely virtualized day strip.
useWeekInfiniteScrollrenders 36,525 day columns, sogridRef's element is roughly 4.5M px wide, andscrollLeftis set totodayIndex * columnWidth(~2.6M px). The strip's owngetBoundingClientRect().xis therefore about -2,600,000 — far outside the window — while its.topis a normal viewport coordinate.Two places trusted that rect:
apps/desktop/src/renderer/src/components/calendar/use-time-grid-marquee.ts:117—buildSelectionfell back togridRect.xwhenever the day column element could not be measured, collapsing the marquee anchor onto the strip's off-screen left edge.anchorRect.yis derived fromgridRect.topand stays correct, so only x goes wrong.apps/desktop/src/renderer/src/components/calendar/popover-position.ts:17—computePopoverPositionclamped only the near edge (Math.max(8, ...)) and, in the "fits to the right" branch, nothing at all. It trusted the anchor to be on-screen, so an off-screen anchor produced an off-screen popover.The CI failure screenshot confirms the split: the marquee overlay ("New Event 8:00 AM - 9:00") renders in the correct column at the correct y, and the popover is nowhere in the 1550x900 viewport. Correct y + wrong x is exactly the signature of the
colRect?.x ?? gridRect?.xfallback.Fix
use-time-grid-marquee.ts— offset the fallback anchor by the column:gridRect.x + columnIndex * columnWidth. Day view has a single column at index 0, so its anchor is identical to before.popover-position.ts— clamp the popover into the viewport on the far edge as well as the near one, so no anchor can push its action row out of reach. This covers every caller: task, note, event, inbox-snooze and quick-create popovers.Deliberately not done: no
test.skip, nofixme, no extra retries, no larger timeout, noforce: true. All of those would hide a real unreachable-Save bug from users.Reproduction and evidence
The E2E does not reproduce on macOS — the failing geometry needs the column element to be momentarily unmeasurable, which only happened on the Linux runner. Verified 10/10 green locally at the exact CI viewport (1550x900, calendar view at x=256 w=974, popover left ~563), so the E2E alone could not prove or disprove anything. The defect is pure geometry, so it is reproduced deterministically at that level instead, using the real CI numbers.
Mutation check — fix reverted, tests go red:
Fix restored:
Whole calendar unit suite:
Test Files 38 passed (38) Tests 282 passed (282)Marquee E2E, 3 consecutive runs of the full file (18/18):
pnpm typecheck16/16 successful ·pnpm lint0 errors (10 pre-existing warnings, none in touched files) ·pnpm docs:impact --strictcovered ·pnpm docs:buildcomplete.Notes
top/lefton a portaled fixed element, no physical Tailwind classes added.