Skip to content

Commit e99a24f

Browse files
authored
fix(ObjectPage): correct position of snapped image (#7151)
1 parent 1516a82 commit e99a24f

File tree

10 files changed

+195
-164
lines changed

10 files changed

+195
-164
lines changed

eslint.config.mjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ const ignorePatterns = {
2626
'**/shared',
2727
'**/examples',
2828
'**/templates',
29-
'**/*.module.css.ts'
29+
'**/*.module.css.ts',
30+
'.yarn'
3031
]
3132
};
3233

packages/main/src/components/ObjectPage/ObjectPage.cy.tsx

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,44 @@ describe('ObjectPage', () => {
511511
cy.wait(200);
512512
cy.findByText('Start SubSection2').should('be.visible');
513513

514+
cy.mount(
515+
<ObjectPage
516+
data-testid="op"
517+
titleArea={DPTitle}
518+
headerArea={DPContent}
519+
footerArea={Footer}
520+
style={{ height: '100vh', scrollBehavior: 'auto' }}
521+
>
522+
{OPContent}
523+
<ObjectPageSection aria-label="Long Section" id="long-section" titleText="Long Section">
524+
<ObjectPageSubSection aria-label="Long Subsection 1" id="sub1" titleText="Long Subsection 1">
525+
<FlexBox style={{ height: '2000px' }} direction="Column" justifyContent="SpaceBetween">
526+
<span>Start SubSection1</span>
527+
<span>End SubSection1</span>
528+
</FlexBox>
529+
</ObjectPageSubSection>
530+
<ObjectPageSubSection aria-label="Long Subsection 2" id="sub2" titleText="Long Subsection 2">
531+
<FlexBox style={{ height: '1000px' }} direction="Column" justifyContent="SpaceBetween">
532+
<span>Start SubSection2</span>
533+
<span>End SubSection2</span>
534+
</FlexBox>
535+
</ObjectPageSubSection>
536+
</ObjectPageSection>
537+
</ObjectPage>
538+
);
539+
cy.wait(100);
540+
541+
cy.get('[ui5-tabcontainer]').findUi5TabByText('Long Section').focus();
542+
cy.realPress('ArrowDown');
543+
cy.get('[ui5-responsive-popover]').should('be.visible');
544+
cy.realPress('ArrowDown');
545+
cy.wait(50);
546+
cy.realPress('ArrowDown');
547+
cy.realPress('Enter');
548+
// wait for scroll
549+
cy.wait(200);
550+
cy.findByText('Start SubSection2').should('be.visible');
551+
514552
cy.mount(
515553
<ObjectPage
516554
data-testid="op"
@@ -525,6 +563,7 @@ describe('ObjectPage', () => {
525563
cy.findByText('Job Information').should('not.exist');
526564
cy.findByTestId('section 1').should('be.visible');
527565

566+
cy.wait(100);
528567
cy.get('[ui5-tabcontainer]').findUi5TabByText('Employment').realClick();
529568
cy.findByText('Job Information').should('be.visible');
530569
cy.findByTestId('section 1').should('not.exist');

packages/main/src/components/ObjectPage/ObjectPage.module.css

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,7 @@
4747
z-index: 4;
4848
cursor: pointer;
4949
display: grid;
50-
51-
[data-component-name='ObjectPageTitle'] {
52-
grid-column: 2;
53-
padding-inline: 0;
54-
}
55-
}
56-
57-
/*:has cannot be nested*/
58-
.header:has([data-component-name='ATwithImageSnappedContentContainer']) [data-component-name='ObjectPageTitle'] {
59-
padding-block-end: 0;
50+
grid-auto-columns: 100%;
6051
}
6152

6253
.headerCollapsed {
@@ -184,11 +175,6 @@
184175
padding: 0;
185176
}
186177

187-
.snappedContent {
188-
grid-column: 1 / span 2;
189-
padding-block-end: 0.5rem;
190-
}
191-
192178
.clickArea {
193179
position: absolute;
194180
inset: 0;

packages/main/src/components/ObjectPage/ObjectPage.stories.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,16 @@ const meta = {
9494
<BreadcrumbsItem>Employee Details</BreadcrumbsItem>
9595
</Breadcrumbs>
9696
}
97-
expandedContent={<MessageStrip>Information (only visible if header content is expanded)</MessageStrip>}
98-
snappedContent={<MessageStrip>Information (only visible if header content is collapsed/snapped)</MessageStrip>}
97+
expandedContent={
98+
<MessageStrip style={{ paddingBlockStart: '0.5rem' }}>
99+
Information (only visible if header content is expanded)
100+
</MessageStrip>
101+
}
102+
snappedContent={
103+
<MessageStrip style={{ paddingBlockStart: '0.5rem' }}>
104+
Information (only visible if header content is collapsed/snapped)
105+
</MessageStrip>
106+
}
99107
>
100108
<ObjectStatus state={ValueState.Positive}>employed</ObjectStatus>
101109
</ObjectPageTitle>

packages/main/src/components/ObjectPage/index.tsx

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ const ObjectPage = forwardRef<ObjectPageDomRef, ObjectPagePropTypes>((props, ref
8787
const objectPageContentRef = useRef<HTMLDivElement>(null);
8888
const selectionScrollTimeout = useRef(null);
8989
const isToggledRef = useRef(false);
90-
const isInitial = useRef(true);
9190
const scrollTimeout = useRef(0);
9291

9392
const [selectedSubSectionId, setSelectedSubSectionId] = useState<undefined | string>(undefined);
@@ -468,16 +467,6 @@ const ObjectPage = forwardRef<ObjectPageDomRef, ObjectPagePropTypes>((props, ref
468467
}
469468
};
470469

471-
const snappedHeaderInObjPage = titleArea && titleArea.props.snappedContent && headerCollapsed === true && !!image;
472-
473-
useEffect(() => {
474-
if (!isInitial.current) {
475-
scrollTimeout.current = performance.now() + 200;
476-
} else {
477-
isInitial.current = false;
478-
}
479-
}, [snappedHeaderInObjPage]);
480-
481470
const renderHeaderContentSection = () => {
482471
if (headerArea?.props) {
483472
return cloneElement(headerArea as ReactElement<ObjectPageHeaderPropTypesWithInternals>, {
@@ -598,33 +587,23 @@ const ObjectPage = forwardRef<ObjectPageDomRef, ObjectPagePropTypes>((props, ref
598587
data-not-clickable={!!preserveHeaderStateOnClick}
599588
aria-roledescription={accessibilityAttributes?.objectPageTopHeader?.ariaRoledescription ?? 'Object Page header'}
600589
className={classNames.header}
601-
style={{
602-
gridAutoColumns: `min-content ${
603-
titleArea && image && headerCollapsed === true ? `calc(100% - 3rem - 1rem)` : '100%'
604-
}`
605-
}}
606590
>
607591
<span
608592
className={classNames.clickArea}
609593
onClick={onTitleClick}
610594
data-component-name="ObjectPageTitleAreaClickElement"
611595
/>
612-
{titleArea && image && headerCollapsed === true && (
613-
<CollapsedAvatar image={image} imageShapeCircle={imageShapeCircle} />
614-
)}
615596
{titleArea &&
616597
cloneElement(titleArea as ReactElement<ObjectPageTitlePropsWithDataAttributes>, {
617598
className: clsx(titleArea?.props?.className),
618599
onToggleHeaderContentVisibility: onTitleClick,
619600
'data-not-clickable': !!preserveHeaderStateOnClick,
620601
'data-header-content-visible': headerArea && headerCollapsed !== true,
621-
'data-is-snapped-rendered-outside': snappedHeaderInObjPage
602+
_snappedAvatar:
603+
!headerArea || (titleArea && image && headerCollapsed === true) ? (
604+
<CollapsedAvatar image={image} imageShapeCircle={imageShapeCircle} />
605+
) : null
622606
})}
623-
{snappedHeaderInObjPage && (
624-
<div className={classNames.snappedContent} data-component-name="ATwithImageSnappedContentContainer">
625-
{titleArea.props.snappedContent}
626-
</div>
627-
)}
628607
</header>
629608
{renderHeaderContentSection()}
630609
{headerArea && titleArea && (

packages/main/src/components/ObjectPage/types/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import type { ObjectPageSectionPropTypes } from '../../ObjectPageSection/index.j
99
import type {
1010
InternalProps as ObjectPageTitlePropTypesWithInternals,
1111
ObjectPageTitlePropTypes
12-
} from '../../ObjectPageTitle/index.js';
12+
} from '../../ObjectPageTitle/types/index.js';
1313

1414
type ObjectPageSectionType = ReactElement<ObjectPageSectionPropTypes> | boolean;
1515

packages/main/src/components/ObjectPageTitle/ObjectPageTitle.cy.tsx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,6 @@ describe('ObjectPageTitle', () => {
127127
cy.findByTestId('page').scrollTo(0, 500);
128128
cy.findByText('snappedContent').should('exist');
129129
cy.findByTestId('expandedContent').should('not.exist');
130-
if (headerContent && image) {
131-
cy.get('[data-component-name="ATwithImageSnappedContentContainer"]').should('exist');
132-
} else {
133-
cy.get('[data-component-name="ATwithImageSnappedContentContainer"]').should('not.exist');
134-
}
135130
});
136131
});
137132
});

packages/main/src/components/ObjectPageTitle/ObjectPageTitle.module.css

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@
6767
}
6868
}
6969

70+
.snappedAvatarContainer:has([data-component-name='ObjectPageCollapsedAvatar']) {
71+
flex-shrink: 0;
72+
}
73+
7074
@container (min-width: 600px) and (max-width: 1023px) {
7175
.title {
7276
padding-block-start: 0.6875rem;
@@ -93,6 +97,11 @@
9397
padding-inline-start: 0;
9498
}
9599

100+
.contentContainer {
101+
flex-basis: 100%;
102+
flex-grow: 1;
103+
}
104+
96105
.content {
97106
display: flex;
98107
flex-shrink: 1.6;

0 commit comments

Comments
 (0)