diff --git a/packages/main/src/components/AnalyticalTable/types/index.ts b/packages/main/src/components/AnalyticalTable/types/index.ts index 1d622ba829a..96b416779cc 100644 --- a/packages/main/src/components/AnalyticalTable/types/index.ts +++ b/packages/main/src/components/AnalyticalTable/types/index.ts @@ -1030,6 +1030,7 @@ export interface AnalyticalTablePropTypes extends Omit { nativeDetail: number; }>, ) => void; + //todo: add cursor pointer when this prop is active in next major version update. /** * Fired when a row is clicked */ diff --git a/packages/main/src/components/ObjectPage/ObjectPage.cy.tsx b/packages/main/src/components/ObjectPage/ObjectPage.cy.tsx index 732c4a56488..134b4aa386a 100644 --- a/packages/main/src/components/ObjectPage/ObjectPage.cy.tsx +++ b/packages/main/src/components/ObjectPage/ObjectPage.cy.tsx @@ -7,7 +7,7 @@ import TitleLevel from '@ui5/webcomponents/dist/types/TitleLevel.js'; import ValueState from '@ui5/webcomponents-base/dist/types/ValueState.js'; import IllustrationMessageType from '@ui5/webcomponents-fiori/dist/types/IllustrationMessageType.js'; import type { CSSProperties } from 'react'; -import { useEffect, useLayoutEffect, useReducer, useRef, useState } from 'react'; +import { useEffect, useLayoutEffect, useReducer, useRef, useState, version as reactVersion } from 'react'; import type { ObjectPagePropTypes } from '../..'; import { CheckBox, @@ -114,7 +114,7 @@ describe('ObjectPage', () => { cy.get('[ui5-tabcontainer]').findUi5TabByText('Section 15').should('have.attr', 'aria-selected', 'true'); if (mode === ObjectPageMode.Default) { - cy.findByTestId('op').scrollTo(0, 4750); + cy.findByTestId('op').scrollTo(0, 4858); cy.findByText('Content 7').should('be.visible'); cy.get('[ui5-tabcontainer]').findUi5TabByText('Section 7').should('have.attr', 'aria-selected', 'true'); @@ -124,7 +124,7 @@ describe('ObjectPage', () => { for (let i = 0; i < 15; i++) { cy.findByText('Add').click(); } - cy.findByTestId('op').scrollTo(0, 4750); + cy.findByTestId('op').scrollTo(0, 4858); cy.findByText('Content 7').should('be.visible'); cy.get('[ui5-tabcontainer]').findUi5TabByText('Section 7').should('have.attr', 'aria-selected', 'true'); @@ -374,12 +374,6 @@ describe('ObjectPage', () => { ); cy.wait(200); - // first titleText should never be displayed (not.be.visible doesn't work here - only invisible for sighted users) - cy.findByText('Goals') - .parent() - .should('have.css', 'width', '1px') - .and('have.css', 'margin', '-1px') - .and('have.css', 'position', 'absolute'); cy.findByText('Employment').should('not.be.visible'); cy.findByText('Test').should('be.visible'); @@ -668,29 +662,52 @@ describe('ObjectPage', () => { cy.findByTestId('footer').should('be.visible'); }); - it('single section - Default mode', () => { - document.body.style.margin = '0px'; - const TestComp = ({ - mode, - height, - withFooter, - }: { - height: CSSProperties['height']; - withFooter?: boolean; - mode: ObjectPageMode; - }) => { - const ref = useRef(null); - const [showCurrentHeights, setShowCurrentHeights] = useState({ offset: null, scroll: null }); - return ( - + const TestSingleSectionComp = ({ + mode, + height, + withFooter, + withSubSections, + }: { + height: CSSProperties['height']; + withFooter?: boolean; + mode: ObjectPageMode; + withSubSections?: boolean; + }) => { + const ref = useRef(null); + const [showCurrentHeights, setShowCurrentHeights] = useState({ offset: null, scroll: null }); + return ( + + {withSubSections ? ( + + +
+ + {JSON.stringify(showCurrentHeights)} +
+
+ +
+
+
+ ) : (
-
- ); - }; - cy.mount(); + )} +
+ ); + }; + + it('single section - Default mode', () => { + document.body.style.margin = '0px'; + + cy.mount(); + + cy.get('[data-component-name="ObjectPageTabContainerPlaceholder"]').should('exist'); + cy.get('[data-component-name="ObjectPageTabContainer"]').should('not.exist'); + cy.findByText('Update Heights').click(); - cy.findByText('{"offset":1080,"scroll":2290}').should('exist'); + cy.findByText('{"offset":1080,"scroll":2280}').should('exist'); cy.findByTestId('op').scrollTo('bottom'); cy.findByText('Update Heights').click({ force: true }); - cy.findByText('{"offset":1080,"scroll":2290}').should('exist'); + cy.findByText('{"offset":1080,"scroll":2280}').should('exist'); - cy.mount(); + cy.mount(); cy.findByText('Update Heights').click(); - cy.findByText('{"offset":1080,"scroll":2330}').should('exist'); + cy.findByText('{"offset":1080,"scroll":2320}').should('exist'); cy.findByTestId('op').scrollTo('bottom'); cy.findByText('Update Heights').click({ force: true }); - cy.findByText('{"offset":1080,"scroll":2330}').should('exist'); + cy.findByText('{"offset":1080,"scroll":2320}').should('exist'); - cy.mount(); + cy.mount(); cy.findByText('Update Heights').click(); cy.findByText('{"offset":1080,"scroll":1080}').should('exist'); @@ -738,7 +764,7 @@ describe('ObjectPage', () => { cy.findByText('Update Heights').click({ force: true }); cy.findByText('{"offset":1080,"scroll":1080}').should('exist'); - cy.mount(); + cy.mount(); cy.findByText('Update Heights').click(); cy.findByText('{"offset":1080,"scroll":1080}').should('exist'); @@ -750,7 +776,7 @@ describe('ObjectPage', () => { cy.findByText('Update Heights').click({ force: true }); cy.findByText('{"offset":1080,"scroll":1080}').should('exist'); - cy.mount(); + cy.mount(); cy.findByText('https://github.com/UI5/webcomponents-react').should('be.visible'); cy.wait(50); @@ -763,67 +789,36 @@ describe('ObjectPage', () => { cy.get('[data-component-name="ObjectPageAnchorBarExpandBtn"]').click(); cy.findByText('https://github.com/UI5/webcomponents-react').should('not.be.visible'); + + cy.log('with subsections'); + cy.mount(); + cy.get('[data-component-name="ObjectPageTabContainerPlaceholder"]').should('exist'); + cy.get('[data-component-name="ObjectPageTabContainer"]').should('not.exist'); }); it('single section - Tab mode', () => { document.body.style.margin = '0px'; - const TestComp = ({ - mode, - height, - withFooter, - }: { - height: CSSProperties['height']; - withFooter?: boolean; - mode: ObjectPageMode; - }) => { - const ref = useRef(null); - const [showCurrentHeights, setShowCurrentHeights] = useState({ offset: null, scroll: null }); - return ( - - -
- - {JSON.stringify(showCurrentHeights)} -
-
-
- ); - }; - cy.mount(); + cy.mount(); + + cy.get('[data-component-name="ObjectPageTabContainerPlaceholder"]').should('exist'); + cy.get('[data-component-name="ObjectPageTabContainer"]').should('not.exist'); + cy.findByText('Update Heights').click(); - cy.findByText('{"offset":1080,"scroll":2290}').should('exist'); + cy.findByText('{"offset":1080,"scroll":2240}').should('exist'); cy.findByTestId('op').scrollTo('bottom'); cy.findByText('Update Heights').click({ force: true }); - cy.findByText('{"offset":1080,"scroll":2290}').should('exist'); + cy.findByText('{"offset":1080,"scroll":2240}').should('exist'); - cy.mount(); + cy.mount(); cy.findByText('Update Heights').click(); - cy.findByText('{"offset":1080,"scroll":2350}').should('exist'); + cy.findByText('{"offset":1080,"scroll":2300}').should('exist'); cy.findByTestId('op').scrollTo('bottom'); cy.findByText('Update Heights').click({ force: true }); - cy.findByText('{"offset":1080,"scroll":2350}').should('exist'); + cy.findByText('{"offset":1080,"scroll":2300}').should('exist'); - cy.mount(); + cy.mount(); cy.findByText('Update Heights').click(); cy.findByText('{"offset":1080,"scroll":1080}').should('exist'); @@ -835,7 +830,7 @@ describe('ObjectPage', () => { cy.findByText('Update Heights').click({ force: true }); cy.findByText('{"offset":1080,"scroll":1080}').should('exist'); - cy.mount(); + cy.mount(); cy.findByText('Update Heights').click(); cy.findByText('{"offset":1080,"scroll":1080}').should('exist'); @@ -847,7 +842,7 @@ describe('ObjectPage', () => { cy.findByText('Update Heights').click({ force: true }); cy.findByText('{"offset":1080,"scroll":1080}').should('exist'); - cy.mount(); + cy.mount(); cy.findByText('https://github.com/UI5/webcomponents-react').should('be.visible'); cy.wait(50); @@ -860,7 +855,13 @@ describe('ObjectPage', () => { cy.get('[data-component-name="ObjectPageAnchorBarExpandBtn"]').click(); cy.findByText('https://github.com/UI5/webcomponents-react').should('not.be.visible'); + + cy.log('with subsections'); + cy.mount(); + cy.get('[data-component-name="ObjectPageTabContainerPlaceholder"]').should('exist'); + cy.get('[data-component-name="ObjectPageTabContainer"]').should('not.exist'); }); + [ObjectPageMode.Default, ObjectPageMode.IconTabBar].forEach((mode) => { it(`ObjectPageSection/SubSection: Custom header & hideTitleText (mode: ${mode})`, () => { document.body.style.margin = '0px'; @@ -923,12 +924,6 @@ describe('ObjectPage', () => { cy.get('[ui5-tabcontainer]').findUi5TabByText('Goals').click(); cy.findByText('Custom Header Section One').should('be.visible'); cy.findByText('toggle titleText1').click({ scrollBehavior: false, force: true }); - // first titleText should never be displayed (not.be.visible doesn't work here - only invisible for sighted users) - cy.findByText('Goals') - .parent() - .should('have.css', 'width', '1px') - .and('have.css', 'margin', '-1px') - .and('have.css', 'position', 'absolute'); cy.findByText('Custom Header Section One').should('be.visible'); cy.get('[ui5-tabcontainer]').findUi5TabByText('Personal').click(); @@ -1853,6 +1848,61 @@ describe('ObjectPage', () => { } cy.focused().should('be.visible').and('have.attr', 'ui5-table-row'); }); + + it('sticky headers', () => { + cy.mount( + + {OPContent} + {OPContentWithCustomHeaderSections} + , + ); + + cy.findByText('Goals').should('not.be.visible'); + cy.get('[ui5-tabcontainer]').findUi5TabByText('Employment').click(); + cy.findByText('Employment').should('not.be.visible'); + cy.findByText('Employee Details').parent().should('have.css', 'position', 'sticky'); + + cy.mount( + + {OPContent} + {OPContentWithCustomHeaderSections} + , + ); + + cy.findByText('Goals').should('be.visible').parent().should('have.css', 'position', 'sticky'); + cy.findByTestId('op').scrollTo(0, 500); + cy.findByText('Goals').should('be.visible'); + cy.get('[ui5-tabcontainer]').findUi5TabByText('Personal').click(); + // has subsections -> only subsection headers are sticky + cy.findByText('Personal').should('be.visible').parent().should('have.css', 'position', 'static'); + cy.findByText('Connect').should('be.visible').parent().should('have.css', 'position', 'sticky'); + cy.findByTestId('op').scrollTo(0, 2500); + cy.findByText('Goals').should('not.be.visible'); + cy.findByText('Payment Information').should('be.visible'); + cy.get('[ui5-tabcontainer]').findUi5TabByText('Custom Header Section One').click(); + cy.findByText('Custom Header Section One').should('be.visible').parent().should('have.css', 'position', 'sticky'); + cy.findByTestId('op').scrollTo(0, 3500); + cy.findByText('Custom Header Section One').should('be.visible'); + cy.get('[ui5-tabcontainer]').findUi5TabByText('Custom Header Section Two').click(); + // has subsections -> only subsection headers are sticky + cy.findByText('Custom Header Section Two').should('be.visible').parent().should('have.css', 'position', 'static'); + cy.findByText('Subsection1').should('be.visible').parent().should('have.css', 'position', 'sticky'); + cy.findByTestId('op').scrollTo(0, 4000); + cy.findByText('Custom Header Section Two').should('not.be.visible'); + cy.findByText('Subsection1').should('be.visible'); + }); }); const DPTitle = ( @@ -1952,6 +2002,44 @@ const OPContent = [ , ]; +const OPContentWithCustomHeaderSections = [ + Custom Header Section One} + > +
+ , + Custom Header Section Two} + > + + + +
)} - {!placeholder && ( + {hasOnlySingleSection && ( +