Skip to content

Commit e885ec9

Browse files
committed
add test
1 parent 1cd5bb0 commit e885ec9

File tree

2 files changed

+44
-2
lines changed

2 files changed

+44
-2
lines changed

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

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import TitleLevel from '@ui5/webcomponents/dist/types/TitleLevel.js';
77
import ValueState from '@ui5/webcomponents-base/dist/types/ValueState.js';
88
import IllustrationMessageType from '@ui5/webcomponents-fiori/dist/types/IllustrationMessageType.js';
99
import type { CSSProperties } from 'react';
10-
import { useEffect, useReducer, useRef, useState } from 'react';
10+
import { useEffect, useLayoutEffect, useReducer, useRef, useState } from 'react';
1111
import type { ObjectPagePropTypes } from '../..';
1212
import {
1313
CheckBox,
@@ -45,6 +45,7 @@ import {
4545
ToolbarButton,
4646
} from '../..';
4747
import { cypressPassThroughTestsFactory } from '@/cypress/support/utils';
48+
import type { TabDomRef } from '../../webComponents/Tab/index.js';
4849

4950
const arbitraryCharsId = `~\`!1@#$%^&*()-_+={}[]:;"'z,<.>/?|♥`;
5051

@@ -1432,6 +1433,45 @@ describe('ObjectPage', () => {
14321433
cy.get('footer').should('have.attr', 'role', 'contentinfo');
14331434
});
14341435

1436+
it('tabRef', () => {
1437+
const TestComp = () => {
1438+
const tabRef = useRef(null);
1439+
1440+
useLayoutEffect(() => {
1441+
if (tabRef.current) {
1442+
requestAnimationFrame(() => {
1443+
tabRef.current.getDomRefInStrip().setAttribute('data-hello', 'true');
1444+
});
1445+
}
1446+
}, []);
1447+
1448+
return (
1449+
<ObjectPage>
1450+
<ObjectPageSection
1451+
id="0"
1452+
titleText="callbackRef"
1453+
tabRef={(node: TabDomRef | null) => {
1454+
if (node) {
1455+
requestAnimationFrame(() => {
1456+
node.getDomRefInStrip().setAttribute('data-hello', 'true');
1457+
});
1458+
}
1459+
}}
1460+
>
1461+
Content
1462+
</ObjectPageSection>
1463+
<ObjectPageSection id="1" titleText="refObject" tabRef={tabRef}>
1464+
Content
1465+
</ObjectPageSection>
1466+
</ObjectPage>
1467+
);
1468+
};
1469+
1470+
cy.mount(<TestComp />);
1471+
1472+
cy.get('[data-hello="true"]').should('be.visible').should('have.length', 2);
1473+
});
1474+
14351475
cypressPassThroughTestsFactory(ObjectPage);
14361476
});
14371477

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ const ObjectPageSection = forwardRef<HTMLElement, ObjectPageSectionPropTypes>((p
8181
...rest
8282
} = props;
8383

84+
const { tabRef: _0, ...propsWithoutOmitted } = rest;
85+
8486
useStylesheet(styleData, ObjectPageSection.displayName);
8587

8688
const htmlId = `ObjectPageSection-${id}`;
@@ -93,7 +95,7 @@ const ObjectPageSection = forwardRef<HTMLElement, ObjectPageSectionPropTypes>((p
9395
role="region"
9496
className={clsx(classNames.section, wrapTitleText && classNames.wrap, className)}
9597
style={style}
96-
{...rest}
98+
{...propsWithoutOmitted}
9799
id={htmlId}
98100
data-component-name="ObjectPageSection"
99101
>

0 commit comments

Comments
 (0)