fix(popover): keep the visibility dropdown on screen (#72) - #73
Conversation
The visibility dropdown clamped only horizontally. When opened near the bottom of the viewport (e.g. a sidebar page low in the tree), it ran off the bottom edge with no scroll and no flip, so its options were unreachable. Add a shared `clampPopoverToViewport` helper that clamps both axes: it aligns/flips horizontally and either flips the popover above the trigger or caps its height so it scrolls when it would overflow the bottom. Wire it into VisibilityPicker and let the dropdown scroll internally. Covered by unit tests for the positioning math. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015x3QVyubHqoamaH2DZ7NA1
|
🤖 Starting work on this now. |
|
🤖 Watch live or take over the session here: https://claude.ai/code/session_0146PGYa9JBFjt8ZxxVDKBLf |
There was a problem hiding this comment.
Reviewed the diff and ran the suite locally: the new clampPopoverToViewport math is correct on both axes, the global box-sizing: border-box (src/app.css:88) means the always-applied max-height won't overflow by padding/border, and src/lib/utils/popoverPosition.test.ts passes (7/7). The scope note holds — DatePicker (src/lib/components/shared/DatePicker.svelte:49-52) already flips vertically, so leaving it is reasonable. This correctly fixes #72 for the visibility picker.
One minor robustness note inline. Heads-up unrelated to this diff: the frontend CI job is failing, but on a pre-existing pnpm audit advisory for the transitive devalue dependency (via svelte-tiptap/svelte-dnd-action) — not caused by this PR.
|
Review posted successfully. SummaryI reviewed PR #73 (imaustink/glyph) — "fix(popover): keep the visibility dropdown on screen (#72)". I checked out the branch, examined the diff, installed deps, and ran the new test file locally (7/7 pass). Verdict: approve-with-a-minor-note. The change is well-scoped and correct:
One inline comment (with a one-click suggestion): on scroll/resize re-measurement, CI note I flagged in the review: the No code was changed…
|
|
Make sure to sync with origin main |
|
🤖 Starting work on this now. |
|
🤖 Watch live or take over the session here: https://claude.ai/code/session_01BZvrVWXhk7cKW5rBFawLWL |
Address review feedback: once a max-height is applied to the dropdown, offsetHeight reports the clamped box rather than the content's natural height, so the flip/placement re-measurement on scroll/resize ran against a capped value. Read scrollHeight instead so placement uses the true content height. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BZvrVWXhk7cKW5rBFawLWL
Picked this PR back up (ai-triage)Addressed the review feedback, fixed the failing check, and synced the branch with Review feedback addressed
Failing check fixed
Branch synced with base
Verification (local)
Deliberately not done
CI is re-running on the new push; the previously-red |
|
Done. The PR is What I did on PR #73Reviewed all feedback:
Changes pushed to
Local verification: Deliberately not done: left ✅ Opened pull request: imaustink/glyph#73 |
Summary
Fixes #72 — "Pop overs should respect screen boundaries".
The visibility picker dropdown (the Private / org / "Share with people…" menu used in the sidebar and on note/task pages) only clamped itself horizontally. When it was opened near the bottom of the viewport — e.g. a page low in the sidebar tree, or on a short/mobile viewport — it opened straight down past the bottom edge with no scroll and no flip, so its options were off-screen and unreachable. This matches the report: "popping up off screen with no way to get that content."
The
DatePickerand the sidebar context menu already clamp both axes; this brings the visibility picker in line.Changes
src/lib/utils/popoverPosition.ts—clampPopoverToViewport(trigger, size, viewport)computes a placement that stays fully on screen on both axes:maxHeightso tall content scrolls internally instead of spilling off-screen.VisibilityPicker.sveltenow uses that helper for positioning and setsoverflow-y: auto+ the computedmax-heighton the dropdown.src/lib/utils/popoverPosition.test.tscover left-align, right-edge flip, left-edge clamp, bottom-edge flip-up, and height-capping.Testing
pnpm test(vitest): 910 passed (68 files, including the new test file).svelte-check: 0 errors, 0 warnings.Scope note
I limited the change to the one component that actually overflowed (the visibility picker).
DatePickerandTreeNodeContextMenualready clamp both axes, so I left them untouched; the new helper is available to consolidate them later if desired.Maintainers: apply the ai-review label to this PR to request an automated code review, or the ai-triage label to have the review feedback addressed and the branch brought back in sync with its base. (The automation can't apply either label to its own PR, so a human needs to add it.)