@@ -296,6 +296,7 @@ var NeonPage = function NeonPage(props) {
296296 var headerRef = ( 0 , _react . useRef ) ( null ) ;
297297 var contentRef = ( 0 , _react . useRef ) ( null ) ;
298298 var sidebarRef = ( 0 , _react . useRef ) ( null ) ;
299+ var sidebarLinksContainerRef = ( 0 , _react . useRef ) ( null ) ;
299300 var belowMd = ( 0 , _useMediaQuery . default ) ( _Theme . default . breakpoints . down ( 'sm' ) ) ;
300301 /**
301302 Sidebar Setup
@@ -312,9 +313,9 @@ var NeonPage = function NeonPage(props) {
312313 var sidebarHashMap = ! hasSidebarLinks ? { } : Object . fromEntries ( sidebarLinks . map ( function ( link , idx ) {
313314 return [ link . hash || '#' , idx ] ;
314315 } ) ) ;
315- var initialCurrectSidebarHash = hasSidebarLinks ? sidebarLinks [ 0 ] . hash || '#' : '#' ;
316+ var initialCurrentSidebarHash = hasSidebarLinks ? sidebarLinks [ 0 ] . hash || '#' : '#' ;
316317
317- var _useState = ( 0 , _react . useState ) ( initialCurrectSidebarHash ) ,
318+ var _useState = ( 0 , _react . useState ) ( initialCurrentSidebarHash ) ,
318319 _useState2 = _slicedToArray ( _useState , 2 ) ,
319320 currentSidebarHash = _useState2 [ 0 ] ,
320321 setCurrentSidebarHash = _useState2 [ 1 ] ;
@@ -345,12 +346,31 @@ var NeonPage = function NeonPage(props) {
345346
346347 var anchor = contentRef . current . querySelector ( hash ) ;
347348 return ! anchor ? - 1 : anchor . offsetTop + headerOffset - stickyOffset - _Theme . default . spacing ( 5 ) ;
348- } , [ hasSidebarLinks , sidebarLinksAsStandaloneChildren , belowMd ] ) ; // For sidebarLinks pages, on successful load, if hash is present then update the current
349+ } , [ hasSidebarLinks , sidebarLinksAsStandaloneChildren , belowMd ] ) ;
350+ /**
351+ Effect - For sidebarLinks pages, on successful load, if hash is present then update the current
352+ */
349353
350354 ( 0 , _react . useLayoutEffect ) ( function ( ) {
351355 if ( error || loading || ! hasSidebarLinks ) {
352356 return function ( ) { } ;
353- } // Handle URL-defined hash on initial load
357+ }
358+
359+ var handleHashChange = function handleHashChange ( ) {
360+ var hash = document . location . hash ;
361+
362+ if ( currentSidebarHash === hash ) {
363+ return ;
364+ }
365+
366+ setCurrentSidebarHash ( hash ) ; // If standard sidebar mode (scroll to content) also perform the scroll offset here
367+
368+ if ( ! sidebarLinksAsStandaloneChildren ) {
369+ window . setTimeout ( function ( ) {
370+ window . scrollTo ( 0 , getSidebarLinkScrollPosition ( hash ) ) ;
371+ } , 0 ) ;
372+ }
373+ } ; // Handle URL-defined hash on initial load
354374
355375
356376 if ( document . location . hash && ! hashInitialized ) {
@@ -359,25 +379,25 @@ var NeonPage = function NeonPage(props) {
359379 document . location . hash = '#' ;
360380 }
361381
362- var hash = document . location . hash ;
382+ handleHashChange ( ) ;
383+ setHashInitialized ( true ) ;
384+ } // Set max-height on sidebar links container when the sidebar is sticky so the links get
385+ // a dedicated scrollbar instead of clipping
363386
364- if ( currentSidebarHash !== hash ) {
365- setCurrentSidebarHash ( hash ) ; // If standard sidebar mode (scroll to content) also perform the scroll offset here
366387
367- if ( ! sidebarLinksAsStandaloneChildren ) {
368- window . setTimeout ( function ( ) {
369- window . scrollTo ( 0 , getSidebarLinkScrollPosition ( hash ) ) ;
370- } , 0 ) ;
371- }
372- }
373-
374- setHashInitialized ( true ) ;
375- } // Set up event listener / handler for user-input scroll events for standard scrolling pages
388+ if ( ! sidebarUnsticky && hasSidebarLinks && sidebarLinksContainerRef . current ) {
389+ var maxHeight = window . innerHeight - sidebarLinksContainerRef . current . offsetTop - 104 ;
390+ sidebarLinksContainerRef . current . style . maxHeight = "" . concat ( maxHeight , "px" ) ;
391+ } // For sidebarLinksAsStandaloneChildren listen for hash changes to trigger a "redirect".
376392
377393
378394 if ( sidebarLinksAsStandaloneChildren ) {
379- return function ( ) { } ;
380- }
395+ window . addEventListener ( 'hashchange' , handleHashChange ) ;
396+ return function ( ) {
397+ window . removeEventListener ( 'hashchange' , handleHashChange ) ;
398+ } ;
399+ } // Set up event listener / handler for user-input scroll events for standard scrolling pages
400+
381401
382402 var handleScroll = function handleScroll ( ) {
383403 var scrollBreaks = sidebarLinks . map ( function ( link ) {
@@ -403,9 +423,9 @@ var NeonPage = function NeonPage(props) {
403423 return function ( ) {
404424 window . removeEventListener ( 'scroll' , handleScroll ) ;
405425 } ;
406- } , [ error , loading , hasSidebarLinks , sidebarLinks , sidebarHashMap , hashInitialized , setHashInitialized , currentSidebarHash , setCurrentSidebarHash , getSidebarLinkScrollPosition , sidebarLinksAsStandaloneChildren ] ) ;
426+ } , [ error , loading , sidebarUnsticky , hasSidebarLinks , sidebarLinks , sidebarHashMap , hashInitialized , setHashInitialized , currentSidebarHash , setCurrentSidebarHash , sidebarLinksContainerRef , getSidebarLinkScrollPosition , sidebarLinksAsStandaloneChildren ] ) ;
407427 /**
408- Drupal CSS Loading
428+ Effect - Load Drupal CSS
409429 */
410430
411431 var _useState7 = ( 0 , _react . useState ) ( false ) ,
@@ -501,6 +521,10 @@ var NeonPage = function NeonPage(props) {
501521 } ) ;
502522 } ) ) ;
503523 } ;
524+ /**
525+ Effect - Fetch notifications
526+ */
527+
504528
505529 ( 0 , _react . useEffect ) ( function ( ) {
506530 if ( fetchNotificationsStatus !== null ) {
@@ -706,6 +730,7 @@ var NeonPage = function NeonPage(props) {
706730 } ;
707731
708732 var fullLinks = /*#__PURE__*/ _react . default . createElement ( _react . default . Fragment , null , /*#__PURE__*/ _react . default . createElement ( "div" , {
733+ ref : sidebarLinksContainerRef ,
709734 className : classes . sidebarLinksContainer
710735 } , sidebarLinks . map ( function ( link ) {
711736 return renderLink ( link ) ;
0 commit comments