Skip to content

Commit

Permalink
Merge pull request #18 from csandman/csandman/fix-menu-placement
Browse files Browse the repository at this point in the history
Csandman/fix menu placement
  • Loading branch information
csandman authored Nov 18, 2021
2 parents 92f578c + 938819b commit 8833b84
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"react/jsx-filename-extension": [
"error",
{
"extensions": [".ts", ".tsx"]
"extensions": [".js", ".tsx"]
}
]
}
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[![npm - chakra-react-select](https://img.shields.io/npm/v/chakra-react-select "chakra-react-select npm")](https://www.npmjs.com/package/chakra-react-select)
[![bundle size - chakra-react-select](https://badgen.net/bundlephobia/min/chakra-react-select "chakra-react-select bundlephobia")](https://bundlephobia.com/result?p=chakra-react-select)
[![bundle size - chakra-react-select](https://badgen.net/bundlephobia/minzip/chakra-react-select "chakra-react-select bundlephobia")](https://bundlephobia.com/result?p=chakra-react-select)
[![Total Downloads - chakra-react-select](https://badgen.net/npm/dt/chakra-react-select?color=blue "chakra-react-select npm downloads")](https://bundlephobia.com/result?p=chakra-react-select)
[![Total Downloads - chakra-react-select](https://badgen.net/npm/dt/chakra-react-select?color=blue "chakra-react-select npm downloads")](https://www.npmjs.com/package/chakra-react-select)

This component is a wrapper for the popular react component [react-select](https://react-select.com/home) made using the UI library [Chakra UI](https://chakra-ui.com/).

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "chakra-react-select",
"version": "1.3.2",
"version": "1.3.3",
"description": "A chakra-ui wrapper for the popular select library react-select",
"license": "MIT",
"author": "Chris Sandvik <chris.sandvik@gmail.com>",
Expand Down
14 changes: 12 additions & 2 deletions src/chakra-react-select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,15 @@ const chakraComponents: ChakraSelectProps["components"] = {
return <Spinner mr={3} {...innerProps} size={spinnerSize} />;
},
// Menu components
Menu: ({ children, innerProps, selectProps: { size } }) => {
Menu: ({
children,
innerProps,
innerRef,
// @ts-ignore `placement` is not recognized as a prop but it's essential
// for the menu placement (and it is passed)
placement,
selectProps: { size },
}) => {
const menuStyles = useMultiStyleConfig("Menu", {});

const chakraTheme = useTheme();
Expand All @@ -252,9 +260,11 @@ const chakraComponents: ChakraSelectProps["components"] = {

return (
<Box
ref={innerRef}
sx={{
position: "absolute",
top: "100%",
...(placement === "bottom" && { top: "100%" }),
...(placement === "top" && { bottom: "100%" }),
my: "8px",
w: "100%",
zIndex: 1,
Expand Down
4 changes: 2 additions & 2 deletions src/types.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Props, ThemeSpacing } from "react-select";
import { CSSWithMultiValues } from "@chakra-ui/react";

export { Theme } from "react-select";
export type { Theme } from "react-select";

export { RecursiveCSSObject } from "@chakra-ui/react";
export type { RecursiveCSSObject } from "@chakra-ui/react";

export type Size = "sm" | "md" | "lg";

Expand Down

0 comments on commit 8833b84

Please sign in to comment.