Skip to content

Commit 703084b

Browse files
refactor(ObjectPage): api alignment (#6047)
BREAKING CHANGE: the props `showHideHeaderButton` and `showTitleInHeaderContent` have been removed. BREAKING CHANGE: the prop `alwaysShowContentHeader` has been renamed to `headerPinned` BREAKING CHANGE: the prop `headerContentPinnable` has been renamed to `hidePinButton` and its logic has been inverted. The pin button is now shown by default. BREAKING CHANGE: the prop `showSubHeaderRight` has been removed as it's not defined by design anymore. --------- Co-authored-by: Lukas Harbarth <[email protected]>
1 parent e0818c4 commit 703084b

File tree

9 files changed

+131
-202
lines changed

9 files changed

+131
-202
lines changed

docs/MigrationGuide.mdx

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -395,21 +395,6 @@ import { Loader } from '@ui5/webcomponents-react';
395395
import { Loader } from '@ui5/webcomponents-react-compat';
396396
```
397397

398-
### ObjectPage
399-
400-
The newly introduced `DynamicPage` web component comes with its own `DynamicPageHeader` and `DynamicPageTitle` components, which are unfortunately incompatible with our `ObjectPage` implementation.
401-
Please use the following components instead:
402-
403-
- `headerContent` now only accepts the `ObjectPageHeader` component.
404-
- `headerTitle` now only accepts the `ObjectPageTitle` component.
405-
406-
**Renamed Props:**
407-
408-
- `a11yConfig` has been renamed to `accessibilityAttributes`
409-
- `a11yConfig.dynamicPageAnchorBar` has been renamed to `accessibilityAttributes.objectPageAnchorBar`
410-
411-
Also, the namings of internal `data-component-name` attributes have been adjusted accordingly. E.g. `data-component-name="DynamicPageTitleSubHeader"` has been renamed to `data-component-name="ObjectPageTitleSubHeader"`
412-
413398
### Text
414399

415400
The `Text` component has been replaced with the `ui5-text` Web Component.
@@ -623,6 +608,36 @@ All Modal helper hooks have been removed. They can be replaced with the regular
623608

624609
The regular methods are now general purpose, so they can be used both inside the React content (components) as well as outside of the React context (redux, redux-saga, etc.).
625610

611+
### ObjectPage
612+
613+
The newly introduced `DynamicPage` web component comes with its own `DynamicPageHeader` and `DynamicPageTitle` components, which are unfortunately incompatible with our `ObjectPage` implementation.
614+
Please use the following components instead:
615+
616+
- `headerContent` now only accepts the `ObjectPageHeader` component.
617+
- `headerTitle` now only accepts the `ObjectPageTitle` component.
618+
619+
**Renamed Props:**
620+
621+
- `a11yConfig` has been renamed to `accessibilityAttributes`
622+
- `a11yConfig.dynamicPageAnchorBar` has been renamed to `accessibilityAttributes.objectPageAnchorBar`
623+
- `alwaysShowContentHeader` has been renamed to `headerPinned`
624+
- `headerContentPinnable` has been renamed to `hidePinButton` and the logic has been inverted. The pin button is now shown by default.
625+
626+
**Removed Props:**
627+
628+
- `showHideHeaderButton`: Hiding the expand/collapse button is not supported by design anymore.
629+
- `showTitleInHeaderContent`: Showing the `headerTitle` as part of the `headerContent` is [not supported by design anymore](https://experience.sap.com/fiori-design-web/object-page/#dynamic-page-header-mandatory).
630+
631+
Also, the namings of internal `data-component-name` attributes have been adjusted accordingly. E.g. `data-component-name="DynamicPageTitleSubHeader"` has been renamed to `data-component-name="ObjectPageTitleSubHeader"`
632+
633+
### ObjectPageTitle
634+
635+
_The `ObjectPageTitle` component is the renamed implementation of the old (React only) `DynamicPageTitle` component._
636+
637+
**Removed Props:**
638+
639+
- `showSubHeaderRight`: Displaying the subheader in the same line as the header is not supported by design anymore.
640+
626641
### ObjectPageSection
627642

628643
The prop `titleText` is now required and the default value `true` has been removed for the `titleTextUppercase` prop to comply with the updated Fiori design guidelines.

packages/cli/src/scripts/codemod/transforms/v2/codemodConfig.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,8 +293,11 @@
293293
},
294294
"ObjectPage": {
295295
"changedProps": {
296-
"a11yConfig": "accessibilityAttributes"
297-
}
296+
"a11yConfig": "accessibilityAttributes",
297+
"alwaysShowContentHeader": "headerPinned",
298+
"headerContentPinnable": "hidePinButton"
299+
},
300+
"removedProps": ["showHideHeaderButton", "showTitleInHeaderContent"]
298301
},
299302
"ObjectStatus": {
300303
"changedProps": {

packages/cli/src/scripts/codemod/transforms/v2/main.cts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,33 @@ export default function transform(file: FileInfo, api: API, options?: Options):
323323
});
324324
}
325325

326+
if (componentName === 'ObjectPage') {
327+
jsxElements.forEach((el) => {
328+
const headerContentPinnable = j(el).find(j.JSXAttribute, { name: { name: 'headerContentPinnable' } });
329+
if (headerContentPinnable.size() === 0) {
330+
j(el)
331+
.find(j.JSXOpeningElement)
332+
.get()
333+
.value.attributes.push(j.jsxAttribute(j.jsxIdentifier('hidePinButton'), null));
334+
isDirty = true;
335+
} else {
336+
const attr = headerContentPinnable.get();
337+
if (
338+
attr.value.value &&
339+
((attr.value.value.type === 'JSXAttribute' && attr.value.value === false) ||
340+
(attr.value.value.type === 'JSXExpressionContainer' && attr.value.value.expression.value === false))
341+
) {
342+
j(el)
343+
.find(j.JSXOpeningElement)
344+
.get()
345+
.value.attributes.push(j.jsxAttribute(j.jsxIdentifier('hidePinButton'), null));
346+
}
347+
headerContentPinnable.remove();
348+
isDirty = true;
349+
}
350+
});
351+
}
352+
326353
if (componentName === 'Page') {
327354
jsxElements.forEach((el) => {
328355
const floatingFooter = j(el).find(j.JSXAttribute, { name: { name: 'floatingFooter' } });

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

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,7 @@ describe('ObjectPage', () => {
4343
headerTitle={<ObjectPageTitle header="Heading" subHeader="SubHeading" />}
4444
headerContent={<ObjectPageHeader>ObjectPageHeader</ObjectPageHeader>}
4545
onToggleHeaderContent={toggle}
46-
headerContentPinnable={false}
47-
showHideHeaderButton
46+
hidePinButton
4847
>
4948
<ObjectPageSection id="section" titleText="Section">
5049
Content
@@ -81,8 +80,6 @@ describe('ObjectPage', () => {
8180
style={{ height: '100vh' }}
8281
headerTitle={<ObjectPageTitle header="Heading" subHeader="SubHeading" />}
8382
headerContent={<ObjectPageHeader>ObjectPageHeader</ObjectPageHeader>}
84-
headerContentPinnable
85-
showHideHeaderButton
8683
onPinnedStateChange={pin}
8784
data-testid="op"
8885
>
@@ -111,7 +108,7 @@ describe('ObjectPage', () => {
111108
cy.findByText('ObjectPageHeader').should('not.be.visible');
112109
});
113110

114-
it('programmatically pin header (`alwaysShowContentHeader`)', () => {
111+
it('programmatically pin header (`headerPinned`)', () => {
115112
document.body.style.margin = '0px';
116113
const TestComp = ({ onPinnedStateChange }: ObjectPagePropTypes) => {
117114
const [pinned, setPinned] = useState(false);
@@ -133,9 +130,7 @@ describe('ObjectPage', () => {
133130
style={{ height: '95vh' }}
134131
headerTitle={<ObjectPageTitle header="Heading" subHeader="SubHeading" />}
135132
headerContent={<ObjectPageHeader>ObjectPageHeader</ObjectPageHeader>}
136-
headerContentPinnable
137-
showHideHeaderButton
138-
alwaysShowContentHeader={pinned}
133+
headerPinned={pinned}
139134
onPinnedStateChange={handlePinChange}
140135
data-testid="op"
141136
>
@@ -212,8 +207,6 @@ describe('ObjectPage', () => {
212207
<div style={{ height: '400px', width: '100%', background: 'lightyellow' }}>ObjectPageHeader</div>
213208
</ObjectPageHeader>
214209
}
215-
headerContentPinnable
216-
showHideHeaderButton
217210
data-testid="op"
218211
>
219212
<ObjectPageSection id="section" titleText="Section">
@@ -394,7 +387,6 @@ describe('ObjectPage', () => {
394387
headerTitle={DPTitle}
395388
headerContent={DPContent}
396389
data-testid="op"
397-
showHideHeaderButton
398390
ref={ref}
399391
footer={withFooter && Footer}
400392
mode={mode}
@@ -420,19 +412,19 @@ describe('ObjectPage', () => {
420412
};
421413
cy.mount(<TestComp height="2000px" mode={ObjectPageMode.Default} />);
422414
cy.findByText('Update Heights').click();
423-
cy.findByText('{"offset":1080,"scroll":2240}').should('exist');
415+
cy.findByText('{"offset":1080,"scroll":2260}').should('exist');
424416

425417
cy.findByTestId('op').scrollTo('bottom');
426418
cy.findByText('Update Heights').click({ force: true });
427-
cy.findByText('{"offset":1080,"scroll":2240}').should('exist');
419+
cy.findByText('{"offset":1080,"scroll":2260}').should('exist');
428420

429421
cy.mount(<TestComp height="2000px" withFooter mode={ObjectPageMode.Default} />);
430422
cy.findByText('Update Heights').click();
431-
cy.findByText('{"offset":1080,"scroll":2290}').should('exist');
423+
cy.findByText('{"offset":1080,"scroll":2310}').should('exist');
432424

433425
cy.findByTestId('op').scrollTo('bottom');
434426
cy.findByText('Update Heights').click({ force: true });
435-
cy.findByText('{"offset":1080,"scroll":2290}').should('exist');
427+
cy.findByText('{"offset":1080,"scroll":2310}').should('exist');
436428

437429
cy.mount(<TestComp height="400px" mode={ObjectPageMode.Default} />);
438430
cy.findByText('Update Heights').click();
@@ -492,7 +484,6 @@ describe('ObjectPage', () => {
492484
headerTitle={DPTitle}
493485
headerContent={DPContent}
494486
data-testid="op"
495-
showHideHeaderButton
496487
ref={ref}
497488
footer={withFooter && Footer}
498489
mode={mode}
@@ -518,19 +509,19 @@ describe('ObjectPage', () => {
518509
};
519510
cy.mount(<TestComp height="2000px" mode={ObjectPageMode.IconTabBar} />);
520511
cy.findByText('Update Heights').click();
521-
cy.findByText('{"offset":1080,"scroll":2240}').should('exist');
512+
cy.findByText('{"offset":1080,"scroll":2260}').should('exist');
522513

523514
cy.findByTestId('op').scrollTo('bottom');
524515
cy.findByText('Update Heights').click({ force: true });
525-
cy.findByText('{"offset":1080,"scroll":2240}').should('exist');
516+
cy.findByText('{"offset":1080,"scroll":2260}').should('exist');
526517

527518
cy.mount(<TestComp height="2000px" withFooter mode={ObjectPageMode.IconTabBar} />);
528519
cy.findByText('Update Heights').click();
529-
cy.findByText('{"offset":1080,"scroll":2300}').should('exist');
520+
cy.findByText('{"offset":1080,"scroll":2320}').should('exist');
530521

531522
cy.findByTestId('op').scrollTo('bottom');
532523
cy.findByText('Update Heights').click({ force: true });
533-
cy.findByText('{"offset":1080,"scroll":2300}').should('exist');
524+
cy.findByText('{"offset":1080,"scroll":2320}').should('exist');
534525

535526
cy.mount(<TestComp height="400px" mode={ObjectPageMode.IconTabBar} />);
536527
cy.findByText('Update Heights').click();

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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
inset-block-start: 0;
4242
z-index: 2;
4343
cursor: pointer;
44+
display: grid;
4445

4546
[data-component-name='ObjectPageTitle'] {
4647
grid-column: 2;
@@ -171,10 +172,6 @@
171172
padding: 0;
172173
}
173174

174-
.titleInHeader {
175-
padding: 0;
176-
}
177-
178175
.snappedContent {
179176
grid-column: 1 / span 2;
180177
}

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

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import {
3232
Text,
3333
Title,
3434
ToggleButton
35-
} from '../..';
35+
} from '../../index.js';
3636
import { ObjectPage } from './index.js';
3737

3838
const meta = {
@@ -48,9 +48,7 @@ const meta = {
4848
},
4949
args: {
5050
mode: ObjectPageMode.Default,
51-
showHideHeaderButton: true,
5251
selectedSectionId: 'goals',
53-
headerContentPinnable: true,
5452
imageShapeCircle: true,
5553
image: SampleImage,
5654
style: { height: '700px' },
@@ -67,7 +65,6 @@ const meta = {
6765
),
6866
headerTitle: (
6967
<ObjectPageTitle
70-
showSubHeaderRight
7168
header="Denise Smith"
7269
subHeader="Senior UI Developer"
7370
actions={
@@ -337,7 +334,6 @@ export const WithCustomOverflowButton: Story = {
337334
<>
338335
<ObjectPage
339336
style={{ width: '1000px' }}
340-
showHideHeaderButton={false}
341337
headerTitle={
342338
<ObjectPageTitle
343339
{...titleProps}
@@ -351,7 +347,6 @@ export const WithCustomOverflowButton: Story = {
351347
/>
352348
<ObjectPage
353349
style={{ width: '1400px' }}
354-
showHideHeaderButton={false}
355350
headerTitle={
356351
<ObjectPageTitle
357352
{...titleProps}

0 commit comments

Comments
 (0)