Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 32 additions & 12 deletions packages/main/src/components/ObjectPage/ObjectPage.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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, 4858);
cy.findByTestId('op').scrollTo(0, 4878);

cy.findByText('Content 7').should('be.visible');
cy.get('[ui5-tabcontainer]').findUi5TabByText('Section 7').should('have.attr', 'aria-selected', 'true');
Expand All @@ -124,7 +124,7 @@ describe('ObjectPage', () => {
for (let i = 0; i < 15; i++) {
cy.findByText('Add').click();
}
cy.findByTestId('op').scrollTo(0, 4858);
cy.findByTestId('op').scrollTo(0, 4878);

cy.findByText('Content 7').should('be.visible');
cy.get('[ui5-tabcontainer]').findUi5TabByText('Section 7').should('have.attr', 'aria-selected', 'true');
Expand Down Expand Up @@ -754,11 +754,11 @@ describe('ObjectPage', () => {

cy.mount(<TestSingleSectionComp height="2000px" withFooter mode={ObjectPageMode.Default} />);
cy.findByText('Update Heights').click();
cy.findByText('{"offset":1080,"scroll":2320}').should('exist');
cy.findByText('{"offset":1080,"scroll":2330}').should('exist');

cy.findByTestId('op').scrollTo('bottom');
cy.findByText('Update Heights').click({ force: true });
cy.findByText('{"offset":1080,"scroll":2320}').should('exist');
cy.findByText('{"offset":1080,"scroll":2330}').should('exist');

cy.mount(<TestSingleSectionComp height="400px" mode={ObjectPageMode.Default} />);
cy.findByText('Update Heights').click();
Expand Down Expand Up @@ -812,19 +812,19 @@ describe('ObjectPage', () => {
cy.get('[data-component-name="ObjectPageTabContainer"]').should('not.exist');

cy.findByText('Update Heights').click();
cy.findByText('{"offset":1080,"scroll":2240}').should('exist');
cy.findByText('{"offset":1080,"scroll":2250}').should('exist');

cy.findByTestId('op').scrollTo('bottom');
cy.findByText('Update Heights').click({ force: true });
cy.findByText('{"offset":1080,"scroll":2240}').should('exist');
cy.findByText('{"offset":1080,"scroll":2250}').should('exist');

cy.mount(<TestSingleSectionComp height="2000px" withFooter mode={ObjectPageMode.IconTabBar} />);
cy.findByText('Update Heights').click();
cy.findByText('{"offset":1080,"scroll":2300}').should('exist');
cy.findByText('{"offset":1080,"scroll":2310}').should('exist');

cy.findByTestId('op').scrollTo('bottom');
cy.findByText('Update Heights').click({ force: true });
cy.findByText('{"offset":1080,"scroll":2300}').should('exist');
cy.findByText('{"offset":1080,"scroll":2310}').should('exist');

cy.mount(<TestSingleSectionComp height="400px" mode={ObjectPageMode.IconTabBar} />);
cy.findByText('Update Heights').click();
Expand Down Expand Up @@ -1299,6 +1299,13 @@ describe('ObjectPage', () => {
>
Select Goals
</button>
<button
onClick={() => {
setSelectedSection(arbitraryCharsId);
}}
>
Select Employment
</button>
<button
onClick={() => {
setSelectedSubSection('personal-payment-information');
Expand Down Expand Up @@ -1349,7 +1356,9 @@ describe('ObjectPage', () => {
cy.wait(100);
cy.findByText('Select Goals').click();
cy.findByText('goals-content').should('be.visible');
cy.get('@change').should('have.callCount', callCount);
if (mode !== 'IconTabBar') {
cy.get('@change').should('have.callCount', callCount);
}
callCount++;
if (mode === 'IconTabBar') {
cy.findByText('personal-connect-content').should('not.exist');
Expand All @@ -1366,7 +1375,9 @@ describe('ObjectPage', () => {
}
cy.findByText('personal-connect-content').should('be.visible');
cy.get('[ui5-tabcontainer]').findUi5TabByText('Personal').should('have.attr', 'aria-selected', 'true');
cy.get('@change').should('have.callCount', callCount);
if (mode !== 'IconTabBar') {
cy.get('@change').should('have.callCount', callCount);
}
callCount++;

cy.get('[ui5-tabcontainer]').findUi5TabByText('Goals').click();
Expand All @@ -1377,14 +1388,23 @@ describe('ObjectPage', () => {
}
cy.findByText('goals-content').should('be.visible');
cy.get('[ui5-tabcontainer]').findUi5TabByText('Goals').should('have.attr', 'aria-selected', 'true');
cy.get('@change').should('have.callCount', callCount);
if (mode !== 'IconTabBar') {
cy.get('@change').should('have.callCount', callCount);
}
callCount++;

// Re-visiting a section should not collapse the header
if (mode === 'IconTabBar' && props.headerArea) {
cy.get('[data-component-name="ObjectPageHeaderContent"]').should('be.visible');
}

cy.findByText('Select Payment Information').click();
cy.findByText('personal-payment-information-content').should('be.visible');
cy.findByText('personal-connect-content').should('not.be.visible');
cy.get('[ui5-tabcontainer]').findUi5TabByText('Personal').should('have.attr', 'aria-selected', 'true');
cy.get('@change').should('have.callCount', callCount);
if (mode !== 'IconTabBar') {
cy.get('@change').should('have.callCount', callCount);
}
callCount++;
},
);
Expand Down
12 changes: 10 additions & 2 deletions packages/main/src/components/ObjectPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -317,11 +317,16 @@ const ObjectPage = forwardRef<ObjectPageDomRef, ObjectPagePropTypes>((props, ref
debouncedOnSectionChange.cancel();
setSelectedSubSectionId(undefined);
setInternalSelectedSectionId((prevSelectedSection) => {
if (prevSelectedSection === newSelectionSectionId) {
if (prevSelectedSection === newSelectionSectionId && mode !== ObjectPageMode.IconTabBar) {
scrollToSection(newSelectionSectionId);
}
return newSelectionSectionId;
});
// Reset scroll for section swap; scrollTimeout preserves current header collapsed/expanded state.
if (mode === ObjectPageMode.IconTabBar) {
scrollTimeout.current = performance.now() + 500;
objectPageRef.current?.scrollTo({ top: 0 });
}
setTabSelectId(newSelectionSectionId);
scrollEvent.current = targetEvent;
if (isMounted && mode === ObjectPageMode.Default) {
Expand All @@ -344,6 +349,7 @@ const ObjectPage = forwardRef<ObjectPageDomRef, ObjectPagePropTypes>((props, ref
}
};
if (mode === ObjectPageMode.IconTabBar) {
scrollTimeout.current = performance.now() + 500;
setInternalSelectedSectionId(selectedSectionId);
getSectionElementById(objectPageContentRef.current, false, selectedSectionId)?.focus({
preventScroll: true,
Expand Down Expand Up @@ -890,7 +896,9 @@ const ObjectPage = forwardRef<ObjectPageDomRef, ObjectPagePropTypes>((props, ref
<div
style={{
height:
((headerCollapsed && !headerPinned) || scrolledHeaderExpanded) && !toggledCollapsedHeaderWasVisible
((headerCollapsed && !headerPinned) || scrolledHeaderExpanded) &&
!toggledCollapsedHeaderWasVisible &&
!(mode === ObjectPageMode.IconTabBar && scrollTimeout.current >= performance.now())
? `${headerContentHeight}px`
: 0,
}}
Expand Down
1 change: 1 addition & 0 deletions packages/main/src/components/ObjectPageSection/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ const ObjectPageSection = forwardRef<HTMLElement, ObjectPageSectionPropTypes>((p
{children}
</div>
</div>
<div className={classNames.outlineSpacerDiv} aria-hidden="true" />
</section>
);
});
Expand Down
Loading