@@ -16,22 +16,18 @@ import {
1616 Sidebar ,
1717 SidebarContent ,
1818 SidebarPanel ,
19- getResizeObserver ,
2019 DrawerContext
2120} from '@patternfly/react-core' ;
2221import { DashboardWrapper } from '@patternfly/react-core/dist/js/demos/DashboardWrapper' ;
23- import mastheadStyles from '@patternfly/react-styles/css/components/Masthead/masthead' ;
24- import breadcrumbStyles from '@patternfly/react-styles/css/components/Breadcrumb/breadcrumb' ;
2522
26- const JumpLinksWrapper = ( { offsetHeight , headings } ) => {
23+ const JumpLinksWrapper = ( { headings } ) => {
2724 const { drawerContentRef } = React . useContext ( DrawerContext ) ;
2825
2926 return (
3027 < JumpLinks
3128 isVertical = { true }
3229 label = "Jump to section"
3330 scrollableRef = { drawerContentRef }
34- offset = { offsetHeight }
3531 expandable = { { default : 'expandable' , md : 'nonExpandable' } }
3632 >
3733 { headings . map ( ( heading ) => (
@@ -47,25 +43,9 @@ const JumpLinksWrapper = ({ offsetHeight, headings }) => {
4743export const JumpLinksWithDrawer = ( ) => {
4844 const headings = [ 'First' , 'Second' , 'Third' , 'Fourth' , 'Fifth' ] ;
4945
50- const [ offsetHeight , setOffsetHeight ] = React . useState ( 0 ) ;
5146 const [ isExpanded , setIsExpanded ] = React . useState ( false ) ;
5247 const drawerRef = React . useRef ( ) ;
5348
54- React . useEffect ( ( ) => {
55- const masthead = document . getElementsByClassName ( mastheadStyles . masthead ) [ 0 ] ;
56- const breadcrumb = document . getElementsByClassName ( breadcrumbStyles . breadcrumb ) [ 0 ] ;
57- const drawerToggleSection = document . getElementById ( 'drawer-toggle' ) ;
58- setOffsetHeight ( masthead . offsetHeight + breadcrumb . offsetHeight + drawerToggleSection . offsetHeight ) ;
59-
60- getResizeObserver (
61- masthead ,
62- ( ) => {
63- setOffsetHeight ( masthead . offsetHeight + breadcrumb . offsetHeight + drawerToggleSection . offsetHeight ) ;
64- } ,
65- true
66- ) ;
67- } , [ ] ) ;
68-
6949 const onCloseClick = ( ) => {
7050 setIsExpanded ( false ) ;
7151 } ;
@@ -95,14 +75,14 @@ export const JumpLinksWithDrawer = () => {
9575 < Sidebar >
9676 < SidebarPanel variant = "sticky" >
9777 < PageSection >
98- < JumpLinksWrapper offsetHeight = { offsetHeight } headings = { headings } />
78+ < JumpLinksWrapper headings = { headings } />
9979 </ PageSection >
10080 </ SidebarPanel >
10181 < SidebarContent >
10282 < PageSection id = "drawer-toggle" stickyOnBreakpoint = { { default : 'top' } } >
10383 < Button onClick = { onToggleClick } > Toggle drawer</ Button >
10484 </ PageSection >
105- < PageSection >
85+ < PageSection hasOverflowScroll >
10686 < Content >
10787 { headings . map ( ( heading ) => (
10888 < div key = { heading } style = { { maxWidth : '800px' , marginBottom : '32px' } } >
0 commit comments