Fix Bug 69107 - Dropdown did not move behind the combobox when the keyboard disappeared.

This commit is contained in:
Tatiana Lopaeva 2024-08-20 17:26:37 +03:00
parent 8687972f98
commit 49f7bc01b1

View File

@ -37,6 +37,7 @@ import { Row } from "./sub-components/Row";
import { DropDownProps } from "./DropDown.types"; import { DropDownProps } from "./DropDown.types";
import { DEFAULT_PARENT_HEIGHT } from "./DropDown.constants"; import { DEFAULT_PARENT_HEIGHT } from "./DropDown.constants";
import { isIOS, isMobile } from "react-device-detect";
const DropDown = ({ const DropDown = ({
directionY = "bottom", directionY = "bottom",
@ -284,12 +285,25 @@ const DropDown = ({
}; };
window.addEventListener("resize", documentResizeListener.current); window.addEventListener("resize", documentResizeListener.current);
if (isIOS && isMobile)
window.visualViewport?.addEventListener(
"resize",
documentResizeListener.current,
);
} }
}, [checkPosition, checkPositionPortal, isDefaultMode, open]); }, [checkPosition, checkPositionPortal, isDefaultMode, open]);
const unbindDocumentResizeListener = React.useCallback(() => { const unbindDocumentResizeListener = React.useCallback(() => {
if (documentResizeListener.current) { if (documentResizeListener.current) {
window.removeEventListener("resize", documentResizeListener.current); window.removeEventListener("resize", documentResizeListener.current);
if (isIOS && isMobile)
window.visualViewport?.removeEventListener(
"resize",
documentResizeListener.current,
);
documentResizeListener.current = null; documentResizeListener.current = null;
} }
}, []); }, []);