Skip to content

fix(ObjectPage): correct position of snapped image #7151

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Apr 7, 2025
Merged
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
3 changes: 2 additions & 1 deletion eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ const ignorePatterns = {
'**/shared',
'**/examples',
'**/templates',
'**/*.module.css.ts'
'**/*.module.css.ts',
'.yarn'
]
};

Expand Down
39 changes: 39 additions & 0 deletions packages/main/src/components/ObjectPage/ObjectPage.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,44 @@ describe('ObjectPage', () => {
cy.wait(200);
cy.findByText('Start SubSection2').should('be.visible');

cy.mount(
<ObjectPage
data-testid="op"
titleArea={DPTitle}
headerArea={DPContent}
footerArea={Footer}
style={{ height: '100vh', scrollBehavior: 'auto' }}
>
{OPContent}
<ObjectPageSection aria-label="Long Section" id="long-section" titleText="Long Section">
<ObjectPageSubSection aria-label="Long Subsection 1" id="sub1" titleText="Long Subsection 1">
<FlexBox style={{ height: '2000px' }} direction="Column" justifyContent="SpaceBetween">
<span>Start SubSection1</span>
<span>End SubSection1</span>
</FlexBox>
</ObjectPageSubSection>
<ObjectPageSubSection aria-label="Long Subsection 2" id="sub2" titleText="Long Subsection 2">
<FlexBox style={{ height: '1000px' }} direction="Column" justifyContent="SpaceBetween">
<span>Start SubSection2</span>
<span>End SubSection2</span>
</FlexBox>
</ObjectPageSubSection>
</ObjectPageSection>
</ObjectPage>
);
cy.wait(100);

cy.get('[ui5-tabcontainer]').findUi5TabByText('Long Section').focus();
cy.realPress('ArrowDown');
cy.get('[ui5-responsive-popover]').should('be.visible');
cy.realPress('ArrowDown');
cy.wait(50);
cy.realPress('ArrowDown');
cy.realPress('Enter');
// wait for scroll
cy.wait(200);
cy.findByText('Start SubSection2').should('be.visible');

cy.mount(
<ObjectPage
data-testid="op"
Expand All @@ -525,6 +563,7 @@ describe('ObjectPage', () => {
cy.findByText('Job Information').should('not.exist');
cy.findByTestId('section 1').should('be.visible');

cy.wait(100);
cy.get('[ui5-tabcontainer]').findUi5TabByText('Employment').realClick();
cy.findByText('Job Information').should('be.visible');
cy.findByTestId('section 1').should('not.exist');
Expand Down
16 changes: 1 addition & 15 deletions packages/main/src/components/ObjectPage/ObjectPage.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,7 @@
z-index: 4;
cursor: pointer;
display: grid;

[data-component-name='ObjectPageTitle'] {
grid-column: 2;
padding-inline: 0;
}
}

/*:has cannot be nested*/
.header:has([data-component-name='ATwithImageSnappedContentContainer']) [data-component-name='ObjectPageTitle'] {
padding-block-end: 0;
grid-auto-columns: 100%;
}

.headerCollapsed {
Expand Down Expand Up @@ -184,11 +175,6 @@
padding: 0;
}

.snappedContent {
grid-column: 1 / span 2;
padding-block-end: 0.5rem;
}

.clickArea {
position: absolute;
inset: 0;
Expand Down
12 changes: 10 additions & 2 deletions packages/main/src/components/ObjectPage/ObjectPage.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,16 @@ const meta = {
<BreadcrumbsItem>Employee Details</BreadcrumbsItem>
</Breadcrumbs>
}
expandedContent={<MessageStrip>Information (only visible if header content is expanded)</MessageStrip>}
snappedContent={<MessageStrip>Information (only visible if header content is collapsed/snapped)</MessageStrip>}
expandedContent={
<MessageStrip style={{ paddingBlockStart: '0.5rem' }}>
Information (only visible if header content is expanded)
</MessageStrip>
}
snappedContent={
<MessageStrip style={{ paddingBlockStart: '0.5rem' }}>
Information (only visible if header content is collapsed/snapped)
</MessageStrip>
}
>
<ObjectStatus state={ValueState.Positive}>employed</ObjectStatus>
</ObjectPageTitle>
Expand Down
29 changes: 4 additions & 25 deletions packages/main/src/components/ObjectPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ const ObjectPage = forwardRef<ObjectPageDomRef, ObjectPagePropTypes>((props, ref
const objectPageContentRef = useRef<HTMLDivElement>(null);
const selectionScrollTimeout = useRef(null);
const isToggledRef = useRef(false);
const isInitial = useRef(true);
const scrollTimeout = useRef(0);

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

const snappedHeaderInObjPage = titleArea && titleArea.props.snappedContent && headerCollapsed === true && !!image;

useEffect(() => {
if (!isInitial.current) {
scrollTimeout.current = performance.now() + 200;
} else {
isInitial.current = false;
}
}, [snappedHeaderInObjPage]);

const renderHeaderContentSection = () => {
if (headerArea?.props) {
return cloneElement(headerArea as ReactElement<ObjectPageHeaderPropTypesWithInternals>, {
Expand Down Expand Up @@ -598,33 +587,23 @@ const ObjectPage = forwardRef<ObjectPageDomRef, ObjectPagePropTypes>((props, ref
data-not-clickable={!!preserveHeaderStateOnClick}
aria-roledescription={accessibilityAttributes?.objectPageTopHeader?.ariaRoledescription ?? 'Object Page header'}
className={classNames.header}
style={{
gridAutoColumns: `min-content ${
titleArea && image && headerCollapsed === true ? `calc(100% - 3rem - 1rem)` : '100%'
}`
}}
>
<span
className={classNames.clickArea}
onClick={onTitleClick}
data-component-name="ObjectPageTitleAreaClickElement"
/>
{titleArea && image && headerCollapsed === true && (
<CollapsedAvatar image={image} imageShapeCircle={imageShapeCircle} />
)}
{titleArea &&
cloneElement(titleArea as ReactElement<ObjectPageTitlePropsWithDataAttributes>, {
className: clsx(titleArea?.props?.className),
onToggleHeaderContentVisibility: onTitleClick,
'data-not-clickable': !!preserveHeaderStateOnClick,
'data-header-content-visible': headerArea && headerCollapsed !== true,
'data-is-snapped-rendered-outside': snappedHeaderInObjPage
_snappedAvatar:
!headerArea || (titleArea && image && headerCollapsed === true) ? (
<CollapsedAvatar image={image} imageShapeCircle={imageShapeCircle} />
) : null
})}
{snappedHeaderInObjPage && (
<div className={classNames.snappedContent} data-component-name="ATwithImageSnappedContentContainer">
{titleArea.props.snappedContent}
</div>
)}
</header>
{renderHeaderContentSection()}
{headerArea && titleArea && (
Expand Down
2 changes: 1 addition & 1 deletion packages/main/src/components/ObjectPage/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import type { ObjectPageSectionPropTypes } from '../../ObjectPageSection/index.j
import type {
InternalProps as ObjectPageTitlePropTypesWithInternals,
ObjectPageTitlePropTypes
} from '../../ObjectPageTitle/index.js';
} from '../../ObjectPageTitle/types/index.js';

type ObjectPageSectionType = ReactElement<ObjectPageSectionPropTypes> | boolean;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,6 @@ describe('ObjectPageTitle', () => {
cy.findByTestId('page').scrollTo(0, 500);
cy.findByText('snappedContent').should('exist');
cy.findByTestId('expandedContent').should('not.exist');
if (headerContent && image) {
cy.get('[data-component-name="ATwithImageSnappedContentContainer"]').should('exist');
} else {
cy.get('[data-component-name="ATwithImageSnappedContentContainer"]').should('not.exist');
}
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@
}
}

.snappedAvatarContainer:has([data-component-name='ObjectPageCollapsedAvatar']) {
flex-shrink: 0;
}

@container (min-width: 600px) and (max-width: 1023px) {
.title {
padding-block-start: 0.6875rem;
Expand All @@ -93,6 +97,11 @@
padding-inline-start: 0;
}

.contentContainer {
flex-basis: 100%;
flex-grow: 1;
}

.content {
display: flex;
flex-shrink: 1.6;
Expand Down
Loading
Loading