style: with prettier (#762)

* style: use pretty quick on staged files

* style: test edit utils

* style: try with lint-staged

* style: test lint application
This commit is contained in:
Laurent Senta
2021-12-06 15:27:18 +01:00
committed by GitHub
parent 31c48af01c
commit c27dce1ab7
7 changed files with 342 additions and 56 deletions

View File

@@ -5,7 +5,7 @@ import { useEffect } from 'react';
/**
* @returns a callback that will close a dropdown if none of its children has
* focus. Must be set as the onBlur callback of children that need to be
* focus. Use the returned function as the onBlur callback of children that need to be
* monitored.
*/
export function useCloseOnBlur(
@@ -36,13 +36,14 @@ export function useCloseOnClickOutside(
container: { current: HTMLDivElement },
setOpen: (open: boolean) => void
): void {
const closeOnClickOutside = useCallback((event: { target: EventTarget | null }) => {
if (
!container.current?.contains(event.target as Node)
) {
setOpen(false);
}
}, [container, setOpen]);
const closeOnClickOutside = useCallback(
(event: { target: EventTarget | null }) => {
if (!container.current?.contains(event.target as Node)) {
setOpen(false);
}
},
[container, setOpen]
);
useEffect(() => {
document.addEventListener('click', closeOnClickOutside);