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 @@ -152,6 +152,7 @@ const TopNav = ({
152
152
if ( ! cache . refs [ menu . id ] ) return menu
153
153
cache . slide [ menu . id ] = true
154
154
const el = cache . refs [ menu . id ]
155
+ if ( ! el ) return menu
155
156
const rect = el . getBoundingClientRect ( )
156
157
return {
157
158
...menu ,
@@ -162,6 +163,7 @@ const TopNav = ({
162
163
163
164
const getMenuCenter = useCallback ( menuId => {
164
165
const el = cache . refs [ menuId ]
166
+ if ( ! el ) return
165
167
const rect = el . getBoundingClientRect ( )
166
168
return ( rect . x || rect . left ) + rect . width / 2
167
169
} , [ cache . refs ] )
@@ -311,6 +313,7 @@ const TopNav = ({
311
313
if ( ! cache . slide [ menu . id ] || ! cache . refs [ menu . id ] ) return
312
314
cache . slide [ menu . id ] = false
313
315
const el = cache . refs [ menu . id ]
316
+ if ( ! el ) return
314
317
const rect = el . getBoundingClientRect ( )
315
318
const relativeX = menu . initialX - ( rect . x || rect . left )
316
319
el . style . transform = `translateX(${ relativeX } px)`
@@ -354,6 +357,7 @@ const TopNav = ({
354
357
if ( ! menuEl ) return
355
358
const rect = menuEl . getBoundingClientRect ( )
356
359
if ( ! prect ) {
360
+ if ( ! menuEl . parentElement ) return
357
361
prect = menuEl . parentElement . getBoundingClientRect ( )
358
362
}
359
363
// add the item if it's overflowing
You can’t perform that action at this time.
0 commit comments