mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
feat: close MainMenu and Library dropdown on item select (#6152)
This commit is contained in:
parent
d4afd66268
commit
1db078a3dc
12 changed files with 178 additions and 62 deletions
19
src/utils.ts
19
src/utils.ts
|
@ -743,3 +743,22 @@ export const isShallowEqual = <T extends Record<string, any>>(
|
|||
}
|
||||
return aKeys.every((key) => objA[key] === objB[key]);
|
||||
};
|
||||
|
||||
// taken from Radix UI
|
||||
// https://github.com/radix-ui/primitives/blob/main/packages/core/primitive/src/primitive.tsx
|
||||
export const composeEventHandlers = <E>(
|
||||
originalEventHandler?: (event: E) => void,
|
||||
ourEventHandler?: (event: E) => void,
|
||||
{ checkForDefaultPrevented = true } = {},
|
||||
) => {
|
||||
return function handleEvent(event: E) {
|
||||
originalEventHandler?.(event);
|
||||
|
||||
if (
|
||||
!checkForDefaultPrevented ||
|
||||
!(event as unknown as Event).defaultPrevented
|
||||
) {
|
||||
return ourEventHandler?.(event);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue