Skip to content

Commit 1853ade

Browse files
yyassi-heartexbmartelvladimirheartex
authored andcommitted
fix: OPTIC-2157: Actions Menu Disappears at High Browser Zoom Levels (#7479)
Co-authored-by: bmartel <[email protected]> Co-authored-by: vladimirheartex <[email protected]> Co-authored-by: yyassi-heartex <[email protected]>
1 parent 205ebf4 commit 1853ade

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

web/libs/core/src/lib/utils/dom.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ export const alignElements = (
9696
align: Align = "bottom-left",
9797
padding = 0,
9898
constrainHeight = false,
99+
openUpwardForShortViewport = true,
99100
) => {
100101
let offsetLeft = 0;
101102
let offsetTop = 0;
@@ -123,25 +124,25 @@ export const alignElements = (
123124
case "bottom-center":
124125
offsetTop = pos.bottom + padding;
125126
offsetLeft = pos.horizontalCenter;
126-
maxHeight = window.scrollX + window.innerHeight - offsetTop;
127+
maxHeight = window.scrollY + window.innerHeight - offsetTop;
127128
break;
128129
case "bottom-left":
129130
offsetTop = pos.bottom + padding;
130131
offsetLeft = pos.horizontalLeft;
131-
maxHeight = window.scrollX + window.innerHeight - offsetTop;
132+
maxHeight = window.scrollY + window.innerHeight - offsetTop;
132133
break;
133134
case "bottom-right":
134135
offsetTop = pos.bottom + padding;
135136
offsetLeft = pos.horizontalRight;
136-
maxHeight = window.scrollX + window.innerHeight - offsetTop;
137+
maxHeight = window.scrollY + window.innerHeight - offsetTop;
137138
break;
138139
default:
139140
break;
140141
}
141142

142-
if (offsetTop < window.scrollX) {
143+
if (offsetTop < window.scrollY || !openUpwardForShortViewport) {
143144
offsetTop = pos.bottom + padding;
144-
maxHeight = window.scrollX + window.innerHeight - offsetTop;
145+
maxHeight = window.scrollY + window.innerHeight - offsetTop;
145146
resultAlign[0] = "bottom";
146147
}
147148
// If the dropdown has more space on the top, then we should align it to the top

web/libs/datamanager/src/components/Common/Dropdown/DropdownComponent.jsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export const Dropdown = React.forwardRef(({ animated = true, visible = false, ..
1818
const { triggerRef } = React.useContext(DropdownContext) ?? {};
1919
const isInline = triggerRef === undefined;
2020

21-
const { children, align, openUpwardForShortViewport } = props;
21+
const { children, align, openUpwardForShortViewport, constrainHeight = false } = props;
2222
const [currentVisible, setVisible] = React.useState(visible);
2323
const [offset, setOffset] = React.useState({});
2424
const [visibility, setVisibility] = React.useState(visible ? "visible" : null);
@@ -31,11 +31,12 @@ export const Dropdown = React.forwardRef(({ animated = true, visible = false, ..
3131
dropdownEl,
3232
align ?? "bottom-left",
3333
0,
34+
constrainHeight,
3435
openUpwardForShortViewport ?? true,
3536
);
3637

3738
setOffset({ left, top });
38-
}, [triggerRef]);
39+
}, [triggerRef, align, openUpwardForShortViewport, constrainHeight]);
3940

4041
const dropdownIndex = React.useMemo(() => {
4142
return lastIndex++;

0 commit comments

Comments
 (0)