Skip to content

fix: OPTIC-2157: Actions Menu Disappears at High Browser Zoom Levels #7479

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
May 7, 2025
Merged
11 changes: 6 additions & 5 deletions web/libs/core/src/lib/utils/dom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ export const alignElements = (
align: Align = "bottom-left",
padding = 0,
constrainHeight = false,
openUpwardForShortViewport = true,
) => {
let offsetLeft = 0;
let offsetTop = 0;
Expand Down Expand Up @@ -123,25 +124,25 @@ export const alignElements = (
case "bottom-center":
offsetTop = pos.bottom + padding;
offsetLeft = pos.horizontalCenter;
maxHeight = window.scrollX + window.innerHeight - offsetTop;
maxHeight = window.scrollY + window.innerHeight - offsetTop;
break;
case "bottom-left":
offsetTop = pos.bottom + padding;
offsetLeft = pos.horizontalLeft;
maxHeight = window.scrollX + window.innerHeight - offsetTop;
maxHeight = window.scrollY + window.innerHeight - offsetTop;
break;
case "bottom-right":
offsetTop = pos.bottom + padding;
offsetLeft = pos.horizontalRight;
maxHeight = window.scrollX + window.innerHeight - offsetTop;
maxHeight = window.scrollY + window.innerHeight - offsetTop;
break;
default:
break;
}

if (offsetTop < window.scrollX) {
if (offsetTop < window.scrollY || !openUpwardForShortViewport) {
offsetTop = pos.bottom + padding;
maxHeight = window.scrollX + window.innerHeight - offsetTop;
maxHeight = window.scrollY + window.innerHeight - offsetTop;
resultAlign[0] = "bottom";
}
// If the dropdown has more space on the top, then we should align it to the top
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const Dropdown = React.forwardRef(({ animated = true, visible = false, ..
const { triggerRef } = React.useContext(DropdownContext) ?? {};
const isInline = triggerRef === undefined;

const { children, align, openUpwardForShortViewport } = props;
const { children, align, openUpwardForShortViewport, constrainHeight = false } = props;
const [currentVisible, setVisible] = React.useState(visible);
const [offset, setOffset] = React.useState({});
const [visibility, setVisibility] = React.useState(visible ? "visible" : null);
Expand All @@ -31,11 +31,12 @@ export const Dropdown = React.forwardRef(({ animated = true, visible = false, ..
dropdownEl,
align ?? "bottom-left",
0,
constrainHeight,
openUpwardForShortViewport ?? true,
);

setOffset({ left, top });
}, [triggerRef]);
}, [triggerRef, align, openUpwardForShortViewport, constrainHeight]);

const dropdownIndex = React.useMemo(() => {
return lastIndex++;
Expand Down
Loading