Skip to content

Commit

Permalink
fix(dropdown): fix dropdown menu unexpected close when closeOnSelect …
Browse files Browse the repository at this point in the history
…is false (#2290)
  • Loading branch information
gtoxlili committed Mar 27, 2024
1 parent cf0d4e4 commit 8e21dc2
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions packages/components/menu/src/menu.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {forwardRef} from "@nextui-org/system";
import {ForwardedRef, ReactElement, Ref} from "react";
import {ForwardedRef, Key, ReactElement, Ref} from "react";

import {UseMenuProps, useMenu} from "./use-menu";
import MenuSection from "./menu-section";
Expand All @@ -18,7 +18,7 @@ function Menu<T extends object>(props: Props<T>, ref: ForwardedRef<HTMLUListElem
hideEmptyContent,
variant,
onClose,
onAction,
onAction: onTopAction,
topContent,
bottomContent,
itemClasses,
Expand All @@ -27,6 +27,12 @@ function Menu<T extends object>(props: Props<T>, ref: ForwardedRef<HTMLUListElem
getEmptyContentProps,
} = useMenu<T>({...props, ref});

const onAction = (key: Key) => {
if (closeOnSelect) {
onTopAction?.(key);
}
};

const content = (
<Component {...getListProps()}>
{!state.collection.size && !hideEmptyContent && (
Expand Down

0 comments on commit 8e21dc2

Please sign in to comment.