File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ interface ContextSubMenuItemProps {
1818 *
1919 * [1]: https://developer.mozilla.org/en-US/docs/Web/API/Node
2020 */
21- const implementsDOMNode = ( node : any ) : boolean => {
21+ const implementsDOMNode = ( node : any ) : node is Node => {
2222 return node && typeof node === 'object' && node . nodeType && node . nodeName ;
2323} ;
2424
@@ -42,7 +42,7 @@ const ContextSubMenuItem: React.FunctionComponent<ContextSubMenuItemProps> = ({
4242 // if the mouse leaves this item, close the sub menu only if the mouse did not enter the sub menu itself
4343 if (
4444 ! subMenuRef . current ||
45- ( implementsDOMNode ( e . relatedTarget ) && ! subMenuRef . current . contains ( e . relatedTarget as Node ) )
45+ ( implementsDOMNode ( e . relatedTarget ) && ! subMenuRef . current . contains ( e . relatedTarget ) )
4646 ) {
4747 setOpen ( false ) ;
4848 }
@@ -65,7 +65,7 @@ const ContextSubMenuItem: React.FunctionComponent<ContextSubMenuItemProps> = ({
6565 closeOnOutsideClick
6666 onRequestClose = { ( e ) => {
6767 // only close the sub menu if clicking anywhere outside the menu item that owns the sub menu
68- if ( ! e || ! nodeRef . current || ( implementsDOMNode ( e . target ) && ! nodeRef . current . contains ( e . target as Node ) ) ) {
68+ if ( ! e || ! nodeRef . current || ( implementsDOMNode ( e . target ) && ! nodeRef . current . contains ( e . target ) ) ) {
6969 setOpen ( false ) ;
7070 }
7171 } }
@@ -78,7 +78,7 @@ const ContextSubMenuItem: React.FunctionComponent<ContextSubMenuItemProps> = ({
7878 // only close the sub menu if the mouse does not enter the item
7979 if (
8080 ! nodeRef . current ||
81- ( implementsDOMNode ( e . relatedTarget ) && ! nodeRef . current . contains ( e . relatedTarget as Node ) )
81+ ( implementsDOMNode ( e . relatedTarget ) && ! nodeRef . current . contains ( e . relatedTarget ) )
8282 ) {
8383 setOpen ( false ) ;
8484 }
You can’t perform that action at this time.
0 commit comments