fix(library): stop popover clicks bubbling + clamp/flip portal placement#78
Conversation
Two follow-up issues caught in PR review: 1. React synthetic events still bubble through the React tree even when the popover is rendered through a portal. The container only stopped `onDoubleClick`, so clicking a playlist row also fired the album / artist tile `onClick` underneath and navigated away mid-pick. Stop `onClick` + `onMouseDown` at the popover root. 2. Portal placement used raw `rect.bottom + 4` / `rect.right - width` with no bounds checks. First-column trigger pushed the popover off the left edge; trigger near the viewport bottom clipped half the menu. Measure the popover via a second ResizeObserver, prefer below then flip above when below would clip, and clamp on both axes with an 8 px viewport margin.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughLe composant ChangesPositionnement adaptatif du popover
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Code Review by Qodo
1.
|
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 28 |
| Duplication | 0 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
Qodo follow-up: the measurement `useLayoutEffect` depended on `rect`, which is updated on every scroll tick. Each tick tore down + remounted the ResizeObserver and forced a synchronous `offsetHeight` read, all to recompute a value that hadn't actually changed. Depend on `anchorEl` only — the ResizeObserver still catches real height changes (locale wrap, content reflow).
Summary
Follow-up to #77 — two issues caught by Qodo's review.
onDoubleClick, so picking a playlist row also fired the album / artist tileonClickunderneath and navigated away mid-pick. The DOM was re-parented but React's synthetic event system still propagates through the React tree.rect.bottom + 4/rect.right - widthcould push the popover off the bottom of the viewport (last visible row) or off the left edge (first-column trigger whererect.right < 224).Fix
onClickandonMouseDown(in addition to existingonDoubleClick) at the popover root. Outside-click detection still works — those handlers usedocumentlisteners withtarget.closest("[data-add-to-playlist-popover]")which short-circuits beforestopPropagationruns.ResizeObserver; prefer placement below the trigger, flip above when below would clip and there's room, then clamp both axes with an 8 px viewport margin.Test plan
+on an album card, then click a playlist row → track added, page does not navigate to the album.+on a card in the first column → popover stays inside the viewport on the left edge.+on a card near the bottom of the viewport → popover flips above the trigger when there's no room below.Summary by CodeRabbit