Skip to content
This repository was archived by the owner on Aug 21, 2024. It is now read-only.

Commit 76cda41

Browse files
[IR-3773]: fix calculateAndApplyOffset regression (#10939)
* reposition for topOverflow in calculateAndApplyOffset * rm popupRef dependency --------- Co-authored-by: Aditya Mitra <55396651+aditya-mitra@users.noreply.github.com>
1 parent 64f7afd commit 76cda41

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

β€Žpackages/common/src/utils/offsets.tsβ€Ž

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,21 @@ export const calculateAndApplyYOffset = (element: HTMLElement | null, additional
3232
const popupBounds = getBounds(element)
3333
const viewportBounds = getViewportBounds(new Bounds())
3434

35+
const overflowTop = viewportBounds.top - (popupBounds?.top ?? 0)
3536
const overflowBottom =
3637
(popupBounds?.top ?? 0) + (popupBounds?.height ?? 0) - (viewportBounds.top + viewportBounds.height)
38+
3739
let offsetY = 0
3840

39-
if (overflowBottom > 0) {
40-
offsetY = -(popupBounds?.height ?? 0) + additionalOffset
41+
if (overflowTop > 0) {
42+
// popup is overflowing at the top, move it down
43+
offsetY = overflowTop
44+
} else if (overflowBottom > 0) {
45+
// popup is overflowing at the bottom, move it up
46+
offsetY = -overflowBottom
4147
}
4248

49+
offsetY += additionalOffset
50+
4351
element.style.transform = `translateY(${offsetY}px)`
4452
}

0 commit comments

Comments
Β (0)