File tree 1 file changed +4
-0
lines changed
1 file changed +4
-0
lines changed Original file line number Diff line number Diff line change @@ -111,6 +111,7 @@ const TopNav = ({
111
111
if ( ! cache . refs [ menu . id ] ) return menu
112
112
cache . slide [ menu . id ] = true
113
113
const el = cache . refs [ menu . id ]
114
+ if ( ! el ) return menu
114
115
const rect = el . getBoundingClientRect ( )
115
116
return {
116
117
...menu ,
@@ -121,6 +122,7 @@ const TopNav = ({
121
122
122
123
const getMenuCenter = useCallback ( menuId => {
123
124
const el = cache . refs [ menuId ]
125
+ if ( ! el ) return
124
126
const rect = el . getBoundingClientRect ( )
125
127
return rect . left + rect . width / 2
126
128
} , [ cache . refs ] )
@@ -267,6 +269,7 @@ const TopNav = ({
267
269
if ( ! cache . slide [ menu . id ] || ! cache . refs [ menu . id ] ) return
268
270
cache . slide [ menu . id ] = false
269
271
const el = cache . refs [ menu . id ]
272
+ if ( ! el ) return
270
273
const rect = el . getBoundingClientRect ( )
271
274
const relativeX = menu . initialX - rect . left
272
275
el . style . transform = `translateX(${ relativeX } px)`
@@ -310,6 +313,7 @@ const TopNav = ({
310
313
if ( ! menuEl ) return
311
314
const rect = menuEl . getBoundingClientRect ( )
312
315
if ( ! prect ) {
316
+ if ( ! menuEl . parentElement ) return
313
317
prect = menuEl . parentElement . getBoundingClientRect ( )
314
318
}
315
319
// add the item if it's overflowing
You can’t perform that action at this time.
0 commit comments