fix: Opening contextual menus sometimes change scroll position

This commit is contained in:
Tom Moor
2023-07-18 21:31:43 -04:00
parent eae6204d55
commit 3c6e2aaac6
3 changed files with 42 additions and 21 deletions

View File

@@ -56,7 +56,10 @@ const ContextMenu: React.FC<Props> = ({
...rest
}) => {
const previousVisible = usePrevious(rest.visible);
const maxHeight = useMenuHeight(rest.visible, rest.unstable_disclosureRef);
const maxHeight = useMenuHeight({
visible: rest.visible,
elementRef: rest.unstable_disclosureRef,
});
const backgroundRef = React.useRef<HTMLDivElement>(null);
const { ui } = useStores();
const { t } = useTranslation();
@@ -147,9 +150,9 @@ const ContextMenu: React.FC<Props> = ({
ref={backgroundRef}
hiddenScrollbars
style={
maxHeight && topAnchor
topAnchor
? {
maxHeight: `min(${maxHeight}px, 75vh)`,
maxHeight,
}
: undefined
}