Skip to content

Commit

Permalink
fix(dropdown): fixing logic gaps
Browse files Browse the repository at this point in the history
  • Loading branch information
gtoxlili committed May 8, 2024
1 parent 0f24d08 commit 4b39f0b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
12 changes: 11 additions & 1 deletion packages/components/dropdown/src/use-dropdown.ts
Expand Up @@ -141,7 +141,17 @@ export function useDropdown(props: UseDropdownProps) {
menuProps,
closeOnSelect,
...mergeProps(props, {
onAction: () => onMenuAction(props?.closeOnSelect),
onAction: (key: any) => {
// @ts-ignore
const item = props?.children?.find((item) => item.key === key);

if (item?.props?.closeOnSelect === false) {
onMenuAction(false);

return;
}
onMenuAction(props?.closeOnSelect);
},
onClose: state.close,
}),
} as MenuProps;
Expand Down
2 changes: 1 addition & 1 deletion packages/hooks/use-aria-menu/src/use-menu-item.ts
Expand Up @@ -144,7 +144,7 @@ export function useMenuItem<T>(
let onAction = isTrigger ? () => {} : props.onAction || data.onAction;
let router = useRouter();
let performAction = (e: PressEvent) => {
if (onAction && closeOnSelect) {
if (onAction) {
// @ts-ignore
onAction(key);
}
Expand Down

0 comments on commit 4b39f0b

Please sign in to comment.