Skip to content
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

Menu shadow fix #209

Merged
merged 1 commit into from Oct 27, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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