-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🐛 (editor) Fix variable dropdown overflow
Closes #209
- Loading branch information
1 parent
e1af6af
commit c1a32ce
Showing
10 changed files
with
125 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { useEventListener } from '@chakra-ui/react' | ||
import { RefObject } from 'react' | ||
|
||
type Handler = (event: MouseEvent) => void | ||
|
||
type Props<T> = { | ||
ref: RefObject<T> | ||
handler: Handler | ||
mouseEvent?: 'mousedown' | 'mouseup' | ||
} | ||
|
||
export const useOutsideClick = <T extends HTMLElement = HTMLElement>({ | ||
ref, | ||
handler, | ||
mouseEvent = 'mousedown', | ||
}: Props<T>): void => { | ||
const triggerHandlerIfOutside = (event: MouseEvent) => { | ||
const el = ref?.current | ||
if (!el || el.contains(event.target as Node)) { | ||
return | ||
} | ||
handler(event) | ||
} | ||
|
||
useEventListener(mouseEvent, triggerHandlerIfOutside) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters