2
0

🚸 (editor) Show toolbar on group click

This commit is contained in:
Baptiste Arnaud
2023-02-23 16:11:51 +01:00
parent 2ff6991ca7
commit 0619c60970
4 changed files with 126 additions and 33 deletions

View File

@@ -6,11 +6,13 @@ type Handler = (event: MouseEvent) => void
type Props<T> = {
ref: RefObject<T>
handler: Handler
capture?: boolean
}
export const useOutsideClick = <T extends HTMLElement = HTMLElement>({
ref,
handler,
capture,
}: Props<T>): void => {
const triggerHandlerIfOutside = (event: MouseEvent) => {
const el = ref?.current
@@ -20,5 +22,7 @@ export const useOutsideClick = <T extends HTMLElement = HTMLElement>({
handler(event)
}
useEventListener('pointerdown', triggerHandlerIfOutside)
useEventListener('pointerdown', triggerHandlerIfOutside, null, {
capture,
})
}