Skip to content

Commit 34554da

Browse files
committed
feat: Add custom click outside handler prop
1 parent b1eec22 commit 34554da

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

src/packages/components/DpMenu/DpMenu.ts

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ interface FloatingOptions {
1111
const props = {
1212
as: { type: String as PropType<string>, default: 'div' },
1313
floating: { type: Object as PropType<FloatingOptions>, default: () => ({ placement: 'bottom', offset: 10 }) },
14+
onClickOutside: { type: Function as PropType<() => void>, default: undefined },
1415
};
1516

1617
export type DpMenuProps = ExtractPropTypes<typeof props>;

src/packages/components/DpMenu/useDpMenu.ts

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export const useDpMenu = (props: DpMenuProps) => {
3535
});
3636

3737
const handleClickOutside = () => {
38+
if (props.onClickOutside) return props.onClickOutside();
3839
closeMenu();
3940
};
4041

0 commit comments

Comments
 (0)