File tree Expand file tree Collapse file tree 1 file changed +14
-11
lines changed
packages/gamut/src/Tip/InfoTip Expand file tree Collapse file tree 1 file changed +14
-11
lines changed Original file line number Diff line number Diff line change @@ -74,16 +74,19 @@ export const InfoTip: React.FC<InfoTipProps> = ({
7474 }
7575 } ;
7676
77- const handleOutsideClick = ( e : MouseEvent ) => {
78- if (
79- wrapperRef . current &&
80- ( e . target instanceof HTMLElement
81- ? ! wrapperRef . current ?. contains ( e ?. target )
82- : true )
83- ) {
84- setTipIsHidden ( true ) ;
85- }
86- } ;
77+ const handleOutsideClick = useCallback (
78+ ( e : MouseEvent ) => {
79+ if (
80+ wrapperRef . current &&
81+ ( e . target instanceof HTMLElement
82+ ? ! wrapperRef . current ?. contains ( e ?. target )
83+ : true )
84+ ) {
85+ setTipIsHidden ( true ) ;
86+ }
87+ } ,
88+ [ setTipIsHidden ]
89+ ) ;
8790
8891 const clickHandler = ( ) => {
8992 const currentTipState = ! isTipHidden ;
@@ -107,7 +110,7 @@ export const InfoTip: React.FC<InfoTipProps> = ({
107110 return ( ) => {
108111 document . removeEventListener ( 'mousedown' , handleOutsideClick ) ;
109112 } ;
110- } ) ;
113+ } , [ handleOutsideClick ] ) ;
111114
112115 useEffect ( ( ) => {
113116 if ( ! isTipHidden && placement === 'floating' ) {
You can’t perform that action at this time.
0 commit comments