Skip to content

Commit

Permalink
Merge pull request #209 from csandman/menu-overflow-fix
Browse files Browse the repository at this point in the history
Menu shadow fix
  • Loading branch information
csandman committed Oct 27, 2022
2 parents 829f779 + 338472b commit 181ca4f
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/chakra-components/menu.tsx
Expand Up @@ -6,6 +6,7 @@ import { MenuIcon } from "@chakra-ui/menu";
import type { SystemStyleObject } from "@chakra-ui/system";
import { useColorModeValue, useMultiStyleConfig } from "@chakra-ui/system";
import type {
CoercedMenuPlacement,
GroupBase,
GroupHeadingProps,
GroupProps,
Expand All @@ -16,6 +17,11 @@ import type {
} from "react-select";
import type { SizeProps, ThemeObject } from "../types";

const alignToControl = (placement: CoercedMenuPlacement) => {
const placementToCSSProp = { bottom: "top", top: "bottom" };
return placement ? placementToCSSProp[placement] : "top";
};

const Menu = <Option, IsMulti extends boolean, Group extends GroupBase<Option>>(
props: MenuProps<Option, IsMulti, Group>
) => {
Expand All @@ -31,12 +37,10 @@ const Menu = <Option, IsMulti extends boolean, Group extends GroupBase<Option>>(

const initialSx: SystemStyleObject = {
position: "absolute",
...(placement === "bottom" && { top: "100%" }),
...(placement === "top" && { bottom: "100%" }),
[alignToControl(placement)]: "100%",
marginY: "8px",
width: "100%",
zIndex: 1,
overflow: "hidden",
};

const sx = chakraStyles?.menu
Expand Down Expand Up @@ -84,6 +88,8 @@ export const MenuList = <
maxHeight: `${maxHeight}px`,
overflowY: "auto",
borderRadius: inputStyles.field?.borderRadius,
position: "relative", // required for offset[Height, Top] > keyboard scroll
WebkitOverflowScrolling: "touch",
};

const sx = chakraStyles?.menuList
Expand Down

0 comments on commit 181ca4f

Please sign in to comment.