Skip to content

Commit 098dda2

Browse files
cursor[bot]cursoragentraymondjacobson
authored
Fix DM reactions popup drifting off-screen on scroll (#14020)
## Summary - Fixes a UI positioning bug where the DM reactions popup could drift upward/off-screen after opening. - Updates Harmony popup scroll tracking to clamp computed top position to viewport bounds when auto-flip/clamping is enabled. ## Root Cause - `Popup` initially clamps its position when opened, but the scroll listener later recomputed `top` without clamping. - In scrollable chat containers this allowed the popup to keep moving upward and leave the viewport. ## Changes - `packages/harmony/src/components/popup/Popup.tsx` - In `watchScroll`, compute `nextTop` and clamp to `[0, window.innerHeight - popupHeight]` unless `disableAutoFlip` is enabled. - Add `disableAutoFlip` to callback deps. ## Validation - Manual code-path validation of popup positioning logic. - Attempted targeted lint command, but local workspace tools were unavailable (`eslint: not found`) in this environment. <div><a href="https://cursor.com/agents/bc-14b2b5b7-8106-5042-8458-54606ab24c62"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/open-in-web-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/open-in-web-light.png"><img alt="Open in Web" width="114" height="28" src="https://cursor.com/assets/images/open-in-web-dark.png"></picture></a>&nbsp;<a href="https://cursor.com/automations/c63aa103-66df-4558-b31d-675358e5c6a1"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/view-automation-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/view-automation-light.png"><img alt="View Automation" width="141" height="28" src="https://cursor.com/assets/images/view-automation-dark.png"></picture></a>&nbsp;</div> Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: Ray Jacobson <raymondjacobson@users.noreply.github.com>
1 parent ad63e39 commit 098dda2

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

  • packages/harmony/src/components/popup

packages/harmony/src/components/popup/Popup.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -325,12 +325,18 @@ export const PopupInternal = forwardRef<
325325
(scrollParent: Element, initialScrollPosition: number) => {
326326
const scrollTop = scrollParent.scrollTop
327327
if (wrapperRef.current) {
328-
wrapperRef.current.style.top = `${
328+
const nextTop =
329329
originalTopPosition.current - scrollTop + initialScrollPosition
330-
}px`
330+
const adjustedTop = disableAutoFlip
331+
? nextTop
332+
: Math.min(
333+
Math.max(0, nextTop),
334+
Math.max(0, window.innerHeight - wrapperRef.current.offsetHeight)
335+
)
336+
wrapperRef.current.style.top = `${adjustedTop}px`
331337
}
332338
},
333-
[wrapperRef, originalTopPosition]
339+
[disableAutoFlip, wrapperRef, originalTopPosition]
334340
)
335341

336342
// Set up scroll listeners

0 commit comments

Comments
 (0)