@@ -113,15 +113,15 @@ const TopNav = ({
113
113
const rect = el . getBoundingClientRect ( )
114
114
return {
115
115
...menu ,
116
- initialX : rect . x
116
+ initialX : rect . x || rect . left
117
117
}
118
118
} ) )
119
119
} , [ cache . refs , cache . slide ] )
120
120
121
121
const getMenuCenter = useCallback ( menuId => {
122
122
const el = cache . refs [ menuId ]
123
123
const rect = el . getBoundingClientRect ( )
124
- return rect . x + rect . width / 2
124
+ return ( rect . x || rect . left ) + rect . width / 2
125
125
} , [ cache . refs ] )
126
126
127
127
const setChosenArrowPos = useCallback ( menuId => {
@@ -263,7 +263,7 @@ const TopNav = ({
263
263
cache . slide [ menu . id ] = false
264
264
const el = cache . refs [ menu . id ]
265
265
const rect = el . getBoundingClientRect ( )
266
- const relativeX = menu . initialX - rect . x
266
+ const relativeX = menu . initialX - ( rect . x || rect . left )
267
267
el . style . transform = `translateX(${ relativeX } px)`
268
268
setTimeout ( ( ) => {
269
269
el . style . transition = 'transform 250ms ease-out'
@@ -344,7 +344,7 @@ const TopNav = ({
344
344
let found = { m1 : null , m2 : null , m3 : null }
345
345
346
346
// If haven't a path just return
347
- if ( ! path_ ) return found
347
+ if ( ! path_ ) return found
348
348
349
349
menuWithId_ . forEach ( level1 => {
350
350
if ( level1 . href && path_ . indexOf ( level1 . href ) > - 1 ) found = { m1 : level1 . id , m2 : null }
@@ -357,14 +357,14 @@ const TopNav = ({
357
357
} else {
358
358
found = { m1 : level1 . id , m2 : level2 . id , m3 : level3 . id }
359
359
}
360
- if ( ! activeLevel3Id && level3 . collapsed ) setforceHideLevel3 ( true )
360
+ if ( ! activeLevel3Id && level3 . collapsed ) setforceHideLevel3 ( true )
361
361
}
362
362
} )
363
363
} )
364
364
level1 . secondaryMenu && level1 . secondaryMenu . forEach ( level3 => {
365
365
if ( level3 . href ) {
366
366
// Check if path have parameters
367
- const href = level3 . href . indexOf ( "?" ) > - 1 ? level3 . href . split ( "?" ) [ 0 ] : level3 . href ;
367
+ const href = level3 . href . indexOf ( '?' ) > - 1 ? level3 . href . split ( '?' ) [ 0 ] : level3 . href
368
368
if ( path_ . indexOf ( href ) > - 1 ) found = { m1 : level1 . id , m3 : level3 . id }
369
369
}
370
370
} )
@@ -390,13 +390,13 @@ const TopNav = ({
390
390
forceExpand = true
391
391
forceM2 = getMenuIdsFromPath ( menuWithId , '/challenges' ) . m2
392
392
}
393
- } else if ( path . indexOf ( '/my-dashboard' ) > - 1 || path . indexOf ( '/members/' + profileHandle ) > - 1 ) {
393
+ } else if ( path . indexOf ( '/my-dashboard' ) > - 1 || path . indexOf ( '/members/' + profileHandle ) > - 1 ) {
394
394
// If My Dashboard and My Profile page
395
395
setShowLevel3 ( true )
396
396
} else if ( path . indexOf ( '/community/learn' ) > - 1 || path . indexOf ( '/thrive/tracks' ) > - 1 ) {
397
397
// Show 3rd level menu to Community [ Overview - How It Works ]
398
- forceM2 = getMenuIdsFromPath ( menuWithId , '/community' ) . m2 ;
399
- } else if ( ! m2 ) {
398
+ forceM2 = getMenuIdsFromPath ( menuWithId , '/community' ) . m2
399
+ } else if ( ! m2 ) {
400
400
setShowLevel3 ( false )
401
401
setforceHideLevel3 ( true )
402
402
}
0 commit comments