This repository was archived by the owner on Sep 1, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -58,13 +58,15 @@ export default class ContextMenu extends AbstractMenu {
5858 const { top, left } = this . getMenuPosition ( x , y ) ;
5959
6060 wrapper ( ( ) => {
61+ if ( ! this . menu ) return ;
6162 this . menu . style . top = `${ top } px` ;
6263 this . menu . style . left = `${ left } px` ;
6364 this . menu . style . opacity = 1 ;
6465 this . menu . style . pointerEvents = 'auto' ;
6566 } ) ;
6667 } ) ;
6768 } else {
69+ if ( ! this . menu ) return ;
6870 this . menu . style . opacity = 0 ;
6971 this . menu . style . pointerEvents = 'none' ;
7072 }
@@ -145,13 +147,16 @@ export default class ContextMenu extends AbstractMenu {
145147 }
146148
147149 getMenuPosition = ( x = 0 , y = 0 ) => {
148- const { innerWidth, innerHeight } = window ;
149- const rect = this . menu . getBoundingClientRect ( ) ;
150- const menuStyles = {
150+ let menuStyles = {
151151 top : y ,
152152 left : x
153153 } ;
154154
155+ if ( ! this . menu ) return menuStyles ;
156+
157+ const { innerWidth, innerHeight } = window ;
158+ const rect = this . menu . getBoundingClientRect ( ) ;
159+
155160 if ( y + rect . height > innerHeight ) {
156161 menuStyles . top -= rect . height ;
157162 }
You can’t perform that action at this time.
0 commit comments