@@ -114,7 +114,7 @@ describe('ObjectPage', () => {
114114 cy . get ( '[ui5-tabcontainer]' ) . findUi5TabByText ( 'Section 15' ) . should ( 'have.attr' , 'aria-selected' , 'true' ) ;
115115
116116 if ( mode === ObjectPageMode . Default ) {
117- cy . findByTestId ( 'op' ) . scrollTo ( 0 , 4750 ) ;
117+ cy . findByTestId ( 'op' ) . scrollTo ( 0 , 4858 ) ;
118118
119119 cy . findByText ( 'Content 7' ) . should ( 'be.visible' ) ;
120120 cy . get ( '[ui5-tabcontainer]' ) . findUi5TabByText ( 'Section 7' ) . should ( 'have.attr' , 'aria-selected' , 'true' ) ;
@@ -124,7 +124,7 @@ describe('ObjectPage', () => {
124124 for ( let i = 0 ; i < 15 ; i ++ ) {
125125 cy . findByText ( 'Add' ) . click ( ) ;
126126 }
127- cy . findByTestId ( 'op' ) . scrollTo ( 0 , 4750 ) ;
127+ cy . findByTestId ( 'op' ) . scrollTo ( 0 , 4858 ) ;
128128
129129 cy . findByText ( 'Content 7' ) . should ( 'be.visible' ) ;
130130 cy . get ( '[ui5-tabcontainer]' ) . findUi5TabByText ( 'Section 7' ) . should ( 'have.attr' , 'aria-selected' , 'true' ) ;
@@ -374,12 +374,6 @@ describe('ObjectPage', () => {
374374 ) ;
375375 cy . wait ( 200 ) ;
376376
377- // first titleText should never be displayed (not.be.visible doesn't work here - only invisible for sighted users)
378- cy . findByText ( 'Goals' )
379- . parent ( )
380- . should ( 'have.css' , 'width' , '1px' )
381- . and ( 'have.css' , 'margin' , '-1px' )
382- . and ( 'have.css' , 'position' , 'absolute' ) ;
383377 cy . findByText ( 'Employment' ) . should ( 'not.be.visible' ) ;
384378 cy . findByText ( 'Test' ) . should ( 'be.visible' ) ;
385379
@@ -712,19 +706,19 @@ describe('ObjectPage', () => {
712706 } ;
713707 cy . mount ( < TestComp height = "2000px" mode = { ObjectPageMode . Default } /> ) ;
714708 cy . findByText ( 'Update Heights' ) . click ( ) ;
715- cy . findByText ( '{"offset":1080,"scroll":2290 }' ) . should ( 'exist' ) ;
709+ cy . findByText ( '{"offset":1080,"scroll":2330 }' ) . should ( 'exist' ) ;
716710
717711 cy . findByTestId ( 'op' ) . scrollTo ( 'bottom' ) ;
718712 cy . findByText ( 'Update Heights' ) . click ( { force : true } ) ;
719- cy . findByText ( '{"offset":1080,"scroll":2290 }' ) . should ( 'exist' ) ;
713+ cy . findByText ( '{"offset":1080,"scroll":2330 }' ) . should ( 'exist' ) ;
720714
721715 cy . mount ( < TestComp height = "2000px" withFooter mode = { ObjectPageMode . Default } /> ) ;
722716 cy . findByText ( 'Update Heights' ) . click ( ) ;
723- cy . findByText ( '{"offset":1080,"scroll":2330 }' ) . should ( 'exist' ) ;
717+ cy . findByText ( '{"offset":1080,"scroll":2370 }' ) . should ( 'exist' ) ;
724718
725719 cy . findByTestId ( 'op' ) . scrollTo ( 'bottom' ) ;
726720 cy . findByText ( 'Update Heights' ) . click ( { force : true } ) ;
727- cy . findByText ( '{"offset":1080,"scroll":2330 }' ) . should ( 'exist' ) ;
721+ cy . findByText ( '{"offset":1080,"scroll":2370 }' ) . should ( 'exist' ) ;
728722
729723 cy . mount ( < TestComp height = "400px" mode = { ObjectPageMode . Default } /> ) ;
730724 cy . findByText ( 'Update Heights' ) . click ( ) ;
@@ -923,12 +917,6 @@ describe('ObjectPage', () => {
923917 cy . get ( '[ui5-tabcontainer]' ) . findUi5TabByText ( 'Goals' ) . click ( ) ;
924918 cy . findByText ( 'Custom Header Section One' ) . should ( 'be.visible' ) ;
925919 cy . findByText ( 'toggle titleText1' ) . click ( { scrollBehavior : false , force : true } ) ;
926- // first titleText should never be displayed (not.be.visible doesn't work here - only invisible for sighted users)
927- cy . findByText ( 'Goals' )
928- . parent ( )
929- . should ( 'have.css' , 'width' , '1px' )
930- . and ( 'have.css' , 'margin' , '-1px' )
931- . and ( 'have.css' , 'position' , 'absolute' ) ;
932920 cy . findByText ( 'Custom Header Section One' ) . should ( 'be.visible' ) ;
933921
934922 cy . get ( '[ui5-tabcontainer]' ) . findUi5TabByText ( 'Personal' ) . click ( ) ;
@@ -1843,6 +1831,55 @@ describe('ObjectPage', () => {
18431831 }
18441832 cy . focused ( ) . should ( 'be.visible' ) . and ( 'have.attr' , 'ui5-table-row' ) ;
18451833 } ) ;
1834+
1835+ it ( 'sticky headers' , ( ) => {
1836+ cy . mount (
1837+ < ObjectPage
1838+ titleArea = { DPTitle }
1839+ headerArea = { DPContent }
1840+ mode = "IconTabBar"
1841+ style = { { height : '1000px' } }
1842+ data-testid = "op"
1843+ >
1844+ { OPContent }
1845+ { OPContentWithCustomHeaderSections }
1846+ </ ObjectPage > ,
1847+ ) ;
1848+
1849+ cy . findByText ( 'Goals' ) . should ( 'not.be.visible' ) ;
1850+ cy . get ( '[ui5-tabcontainer]' ) . findUi5TabByText ( 'Employment' ) . click ( ) ;
1851+ cy . findByText ( 'Employment' ) . should ( 'not.be.visible' ) ;
1852+ cy . findByText ( 'Employee Details' ) . parent ( ) . should ( 'have.css' , 'position' , 'sticky' ) ;
1853+
1854+ cy . mount (
1855+ < ObjectPage titleArea = { DPTitle } headerArea = { DPContent } style = { { height : '1000px' } } data-testid = "op" >
1856+ { OPContent }
1857+ { OPContentWithCustomHeaderSections }
1858+ </ ObjectPage > ,
1859+ ) ;
1860+
1861+ cy . findByText ( 'Goals' ) . should ( 'be.visible' ) . parent ( ) . should ( 'have.css' , 'position' , 'sticky' ) ;
1862+ cy . findByTestId ( 'op' ) . scrollTo ( 0 , 500 ) ;
1863+ cy . findByText ( 'Goals' ) . should ( 'be.visible' ) ;
1864+ cy . get ( '[ui5-tabcontainer]' ) . findUi5TabByText ( 'Personal' ) . click ( ) ;
1865+ // has subsections -> only subsection headers are sticky
1866+ cy . findByText ( 'Personal' ) . should ( 'be.visible' ) . parent ( ) . should ( 'have.css' , 'position' , 'static' ) ;
1867+ cy . findByText ( 'Connect' ) . should ( 'be.visible' ) . parent ( ) . should ( 'have.css' , 'position' , 'sticky' ) ;
1868+ cy . findByTestId ( 'op' ) . scrollTo ( 0 , 2500 ) ;
1869+ cy . findByText ( 'Goals' ) . should ( 'not.be.visible' ) ;
1870+ cy . findByText ( 'Payment Information' ) . should ( 'be.visible' ) ;
1871+ cy . get ( '[ui5-tabcontainer]' ) . findUi5TabByText ( 'Custom Header Section One' ) . click ( ) ;
1872+ cy . findByText ( 'Custom Header Section One' ) . should ( 'be.visible' ) . parent ( ) . should ( 'have.css' , 'position' , 'sticky' ) ;
1873+ cy . findByTestId ( 'op' ) . scrollTo ( 0 , 3500 ) ;
1874+ cy . findByText ( 'Custom Header Section One' ) . should ( 'be.visible' ) ;
1875+ cy . get ( '[ui5-tabcontainer]' ) . findUi5TabByText ( 'Custom Header Section Two' ) . click ( ) ;
1876+ // has subsections -> only subsection headers are sticky
1877+ cy . findByText ( 'Custom Header Section Two' ) . should ( 'be.visible' ) . parent ( ) . should ( 'have.css' , 'position' , 'static' ) ;
1878+ cy . findByText ( 'Subsection1' ) . should ( 'be.visible' ) . parent ( ) . should ( 'have.css' , 'position' , 'sticky' ) ;
1879+ cy . findByTestId ( 'op' ) . scrollTo ( 0 , 4000 ) ;
1880+ cy . findByText ( 'Custom Header Section Two' ) . should ( 'not.be.visible' ) ;
1881+ cy . findByText ( 'Subsection1' ) . should ( 'be.visible' ) ;
1882+ } ) ;
18461883} ) ;
18471884
18481885const DPTitle = (
@@ -1942,6 +1979,44 @@ const OPContent = [
19421979 </ ObjectPageSection > ,
19431980] ;
19441981
1982+ const OPContentWithCustomHeaderSections = [
1983+ < ObjectPageSection
1984+ key = { 'customheader1' }
1985+ titleText = "Custom Header Section One"
1986+ hideTitleText
1987+ id = "custom1"
1988+ header = { < Title > Custom Header Section One</ Title > }
1989+ >
1990+ < div style = { { width : '100%' , height : '200px' , background : 'lightgreen' } } />
1991+ </ ObjectPageSection > ,
1992+ < ObjectPageSection
1993+ key = { 'customheader2' }
1994+ titleText = "Custom Header Section Two"
1995+ hideTitleText
1996+ id = "custom2"
1997+ header = { < MessageStrip hideCloseButton > Custom Header Section Two</ MessageStrip > }
1998+ >
1999+ < ObjectPageSubSection
2000+ titleText = "Subsection1"
2001+ id = "sub1"
2002+ actions = {
2003+ < >
2004+ < Button design = { ButtonDesign . Emphasized } style = { { minWidth : '120px' } } >
2005+ Custom Action
2006+ </ Button >
2007+ < Button design = { ButtonDesign . Transparent } icon = "action-settings" tooltip = "settings" />
2008+ < Button design = { ButtonDesign . Transparent } icon = "download" tooltip = "download" />
2009+ </ >
2010+ }
2011+ >
2012+ < div style = { { width : '100%' , height : '300px' , background : 'cadetblue' } } />
2013+ </ ObjectPageSubSection >
2014+ < ObjectPageSubSection titleText = "Subsection2" id = "sub2" >
2015+ < div style = { { width : '100%' , height : '300px' , background : 'cadetblue' } } />
2016+ </ ObjectPageSubSection >
2017+ </ ObjectPageSection > ,
2018+ ] ;
2019+
19452020const HeaderWithLargeForm = (
19462021 < ObjectPageHeader >
19472022 < Form layout = "S1 M2 L2 XL2" >
0 commit comments