File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -142,6 +142,10 @@ export const JumpLinks: React.FunctionComponent<JumpLinksProps> = ({
142142 return ;
143143 }
144144 const scrollPosition = Math . ceil ( scrollableElement . scrollTop + offset ) ;
145+ // Take into account the last section not having enough content to trigger a scroll position; without
146+ // checking if at the bottom of the scroll container, the last JumpLinksItem never becomes "active".
147+ const isAtBottom =
148+ Math . ceil ( scrollableElement . scrollTop + scrollableElement . clientHeight ) >= scrollableElement . scrollHeight ;
145149 window . requestAnimationFrame ( ( ) => {
146150 let newScrollItems = scrollItems ;
147151 // Items might have rendered after this component or offsetTop values may need
@@ -153,6 +157,11 @@ export const JumpLinks: React.FunctionComponent<JumpLinksProps> = ({
153157 setScrollItems ( newScrollItems ) ;
154158 }
155159
160+ if ( isAtBottom ) {
161+ const lastIndex = newScrollItems . length - 1 ;
162+ return setActiveIndex ( lastIndex ) ;
163+ }
164+
156165 const scrollElements = newScrollItems
157166 . map ( ( e , index ) => ( {
158167 y : e ? e . offsetTop : null ,
Original file line number Diff line number Diff line change @@ -72,7 +72,7 @@ export const JumpLinksScrollspy: React.FunctionComponent = () => {
7272 isVertical = { isVertical }
7373 isCentered = { ! isVertical }
7474 label = "Jump to section"
75- scrollableSelector = ".pf-v6-c-page__main-container "
75+ scrollableSelector = ".pf-v6-c-page__main"
7676 offset = { offsetHeight }
7777 expandable = { { default : isVertical ? 'expandable' : 'nonExpandable' , md : 'nonExpandable' } }
7878 isExpanded
You can’t perform that action at this time.
0 commit comments