File tree Expand file tree Collapse file tree 1 file changed +13
-4
lines changed
src/lib_components/components/NeonPage Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -422,9 +422,6 @@ const NeonPage = (props) => {
422
422
if ( sidebarLinks . length === 5 ) {
423
423
return sidebarLinks [ 3 ] . hash ;
424
424
}
425
- if ( sidebarLinks . length === 7 ) {
426
- return sidebarLinks [ 1 ] . hash ;
427
- }
428
425
return '#' ;
429
426
} ) ( ) ;
430
427
const currentSidebarHash = initialCurrentSidebarHash ;
@@ -438,7 +435,19 @@ const NeonPage = (props) => {
438
435
const headerOffset = ( headerRef . current || { } ) . offsetHeight || 0 ;
439
436
const stickyOffset = belowMd ? ( sidebarRef . current || { } ) . offsetHeight || 0 : 0 ;
440
437
if ( hash === '#' ) { return 0 ; }
441
- const anchor = contentRef . current . querySelector ( hash ) ;
438
+ let selector = null ;
439
+ try {
440
+ const url = new URL ( hash , window . location . origin ) ;
441
+ selector = url . hash ;
442
+ } catch {
443
+ if ( hash . startsWith ( '#' ) ) {
444
+ selector = hash ;
445
+ }
446
+ }
447
+ if ( ! selector ) {
448
+ return - 1 ;
449
+ }
450
+ const anchor = contentRef . current . querySelector ( selector ) ;
442
451
return ! anchor ? - 1 : anchor . offsetTop + headerOffset - stickyOffset - Theme . spacing ( 5 ) ;
443
452
} , [ hasSidebarLinks , sidebarLinksAsStandaloneChildren , belowMd ] ) ;
444
453
You can’t perform that action at this time.
0 commit comments