+
{Children.map(children, (child: any) =>
cloneElement(child, {
diff --git a/packages/main/src/components/SideNavigationListItem/SideNavigationListItem.test.tsx b/packages/main/src/components/SideNavigationListItem/SideNavigationListItem.test.tsx
index 0b130c362e6..9a01b489254 100644
--- a/packages/main/src/components/SideNavigationListItem/SideNavigationListItem.test.tsx
+++ b/packages/main/src/components/SideNavigationListItem/SideNavigationListItem.test.tsx
@@ -1,4 +1,4 @@
-import { mountThemedComponent } from '@shared/tests/utils';
+import { createPassThroughPropsTest, mountThemedComponent } from '@shared/tests/utils';
import { ContentDensity } from '@ui5/webcomponents-react/lib/ContentDensity';
import { SideNavigationListItem } from '@ui5/webcomponents-react/lib/SideNavigationListItem';
import React from 'react';
@@ -28,4 +28,6 @@ describe('SideNavigationListItem', () => {
});
expect(wrapper.render()).toMatchSnapshot();
});
+
+ createPassThroughPropsTest(SideNavigationListItem);
});
diff --git a/packages/main/src/components/SideNavigationListItem/__snapshots__/SideNavigationListItem.test.tsx.snap b/packages/main/src/components/SideNavigationListItem/__snapshots__/SideNavigationListItem.test.tsx.snap
index 44413f8cfdb..7917b166a3c 100644
--- a/packages/main/src/components/SideNavigationListItem/__snapshots__/SideNavigationListItem.test.tsx.snap
+++ b/packages/main/src/components/SideNavigationListItem/__snapshots__/SideNavigationListItem.test.tsx.snap
@@ -5,6 +5,7 @@ exports[`SideNavigationListItem Basic 1`] = `
class="SideNavigationListItem--listItem-"
data-has-children="false"
data-id="home"
+ id="home"
type="Active"
>
diff --git a/packages/main/src/components/SideNavigationListItem/index.tsx b/packages/main/src/components/SideNavigationListItem/index.tsx
index 88867311000..7ed00fb0d25 100644
--- a/packages/main/src/components/SideNavigationListItem/index.tsx
+++ b/packages/main/src/components/SideNavigationListItem/index.tsx
@@ -1,4 +1,7 @@
+import '@ui5/webcomponents-icons/dist/icons/navigation-down-arrow.js';
+import '@ui5/webcomponents-icons/dist/icons/navigation-right-arrow.js';
import { StyleClassHelper } from '@ui5/webcomponents-react-base/lib/StyleClassHelper';
+import { usePassThroughHtmlProps } from '@ui5/webcomponents-react-base/lib/usePassThroughHtmlProps';
import { ContentDensity } from '@ui5/webcomponents-react/lib/ContentDensity';
import { CustomListItem } from '@ui5/webcomponents-react/lib/CustomListItem';
import { Icon } from '@ui5/webcomponents-react/lib/Icon';
@@ -8,8 +11,6 @@ import { PopoverVerticalAlign } from '@ui5/webcomponents-react/lib/PopoverVertic
import { SideNavigationOpenState } from '@ui5/webcomponents-react/lib/SideNavigationOpenState';
import { StandardListItem } from '@ui5/webcomponents-react/lib/StandardListItem';
import { Text } from '@ui5/webcomponents-react/lib/Text';
-import '@ui5/webcomponents-icons/dist/icons/navigation-down-arrow.js';
-import '@ui5/webcomponents-icons/dist/icons/navigation-right-arrow.js';
import React, {
Children,
cloneElement,
@@ -94,6 +95,8 @@ const SideNavigationListItem: FC = forwardRef(
childCount > 0 &&
!!validChildren.find((child: any) => child.props.id === props['selectedId']);
+ const passThroughProps = usePassThroughHtmlProps(props);
+
const customListItemCommonProps = {
ref,
className: listItemClasses.valueOf(),
@@ -102,7 +105,8 @@ const SideNavigationListItem: FC = forwardRef(
style,
'data-id': id,
'data-has-children': childCount > 0,
- 'data-is-child': props['isChild']
+ 'data-is-child': props['isChild'],
+ ...passThroughProps
};
const popoverRef = useRef();
diff --git a/packages/main/src/components/Spinner/Spinner.test.tsx b/packages/main/src/components/Spinner/Spinner.test.tsx
index 584d393f9a7..0d504acaf0e 100644
--- a/packages/main/src/components/Spinner/Spinner.test.tsx
+++ b/packages/main/src/components/Spinner/Spinner.test.tsx
@@ -1,4 +1,4 @@
-import { renderThemedComponent } from '@shared/tests/utils';
+import { createPassThroughPropsTest, renderThemedComponent } from '@shared/tests/utils';
import React from 'react';
import { Size } from '@ui5/webcomponents-react/lib/Size';
import { Spinner } from '@ui5/webcomponents-react/lib/Spinner';
@@ -28,4 +28,6 @@ describe('Spinner', () => {
const wrapper = renderThemedComponent();
expect(wrapper).toMatchSnapshot();
});
+
+ createPassThroughPropsTest(Spinner);
});
diff --git a/packages/main/src/components/Spinner/index.tsx b/packages/main/src/components/Spinner/index.tsx
index 0fa6f6b3698..5ced8903cfd 100644
--- a/packages/main/src/components/Spinner/index.tsx
+++ b/packages/main/src/components/Spinner/index.tsx
@@ -1,4 +1,5 @@
import { StyleClassHelper } from '@ui5/webcomponents-react-base/lib/StyleClassHelper';
+import { usePassThroughHtmlProps } from '@ui5/webcomponents-react-base/lib/usePassThroughHtmlProps';
import { Size } from '@ui5/webcomponents-react/lib/Size';
import React, { FC, forwardRef, RefObject, useEffect, useState } from 'react';
import { createUseStyles } from 'react-jss';
@@ -35,6 +36,8 @@ const Spinner: FC = forwardRef((props: SpinnerProps, ref: RefObjec
}
}, []);
+ const passThroughProps = usePassThroughHtmlProps(props);
+
if (!isVisible) {
return null;
}
@@ -52,6 +55,7 @@ const Spinner: FC = forwardRef((props: SpinnerProps, ref: RefObjec
title={tooltip || 'Please wait'}
slot={slot}
style={style}
+ {...passThroughProps}
>
Loading...
diff --git a/packages/main/src/components/Text/Text.test.tsx b/packages/main/src/components/Text/Text.test.tsx
index 0b192d14ebf..0bf22bed463 100644
--- a/packages/main/src/components/Text/Text.test.tsx
+++ b/packages/main/src/components/Text/Text.test.tsx
@@ -1,4 +1,4 @@
-import { mountThemedComponent } from '@shared/tests/utils';
+import { createPassThroughPropsTest, mountThemedComponent } from '@shared/tests/utils';
import React from 'react';
import { Text } from '@ui5/webcomponents-react/lib/Text';
@@ -28,4 +28,6 @@ describe('Text', () => {
const wrapper = mountThemedComponent(
Test);
expect(window.getComputedStyle(wrapper.getDOMNode()).width).toEqual('300px');
});
+
+ createPassThroughPropsTest(Text);
});
diff --git a/packages/main/src/components/Text/index.tsx b/packages/main/src/components/Text/index.tsx
index 913eb066dbf..99e0d6da793 100644
--- a/packages/main/src/components/Text/index.tsx
+++ b/packages/main/src/components/Text/index.tsx
@@ -1,4 +1,5 @@
import { StyleClassHelper } from '@ui5/webcomponents-react-base/lib/StyleClassHelper';
+import { usePassThroughHtmlProps } from '@ui5/webcomponents-react-base/lib/usePassThroughHtmlProps';
import React, { CSSProperties, FC, forwardRef, ReactNode, Ref } from 'react';
import { createUseStyles } from 'react-jss';
import { CommonProps } from '../../interfaces/CommonProps';
@@ -42,8 +43,18 @@ const Text: FC
= forwardRef((props: TextProps, ref: Ref
+
{children}
);
diff --git a/packages/main/src/components/VariantManagement/VariantManagement.test.tsx b/packages/main/src/components/VariantManagement/VariantManagement.test.tsx
index abb4b3d3b77..142af03ef9b 100644
--- a/packages/main/src/components/VariantManagement/VariantManagement.test.tsx
+++ b/packages/main/src/components/VariantManagement/VariantManagement.test.tsx
@@ -1,8 +1,11 @@
-import { mountThemedComponent } from '@shared/tests/utils';
-import React from 'react';
+import { createPassThroughPropsTest, mountThemedComponent } from '@shared/tests/utils';
import { VariantManagement } from '@ui5/webcomponents-react/lib/VariantManagement';
+import React from 'react';
-const variantItems = [{ label: 'Variant 1', key: '1' }, { label: 'Variant 2', key: '2' }];
+const variantItems = [
+ { label: 'Variant 1', key: '1' },
+ { label: 'Variant 2', key: '2' }
+];
describe('VariantManagement', () => {
test('Render without crashing', () => {
@@ -36,4 +39,6 @@ describe('VariantManagement', () => {
//
//
// });
+
+ createPassThroughPropsTest(VariantManagement, { variantItems });
});
diff --git a/packages/main/src/components/VariantManagement/index.tsx b/packages/main/src/components/VariantManagement/index.tsx
index a2b21452c94..dfd657e8b04 100644
--- a/packages/main/src/components/VariantManagement/index.tsx
+++ b/packages/main/src/components/VariantManagement/index.tsx
@@ -1,4 +1,6 @@
+import '@ui5/webcomponents-icons/dist/icons/navigation-down-arrow';
import { Event } from '@ui5/webcomponents-react-base/lib/Event';
+import { usePassThroughHtmlProps } from '@ui5/webcomponents-react-base/lib/usePassThroughHtmlProps';
import { Button } from '@ui5/webcomponents-react/lib/Button';
import { ButtonDesign } from '@ui5/webcomponents-react/lib/ButtonDesign';
import { List } from '@ui5/webcomponents-react/lib/List';
@@ -9,7 +11,6 @@ import { Popover } from '@ui5/webcomponents-react/lib/Popover';
import { StandardListItem } from '@ui5/webcomponents-react/lib/StandardListItem';
import { Title } from '@ui5/webcomponents-react/lib/Title';
import { TitleLevel } from '@ui5/webcomponents-react/lib/TitleLevel';
-import '@ui5/webcomponents-icons/dist/icons/navigation-down-arrow';
import React, { FC, forwardRef, Ref, useCallback, useEffect, useMemo, useState } from 'react';
import { createUseStyles } from 'react-jss';
import { CommonProps } from '../../interfaces/CommonProps';
@@ -83,7 +84,7 @@ const VariantManagement: FC = forwardRef(
const classes = useStyles();
const [open, setOpen] = useState(false);
const [selectedKey, setSelectedKey] = useState(
- initialSelectedKey ? initialSelectedKey : variantItems.length ? variantItems[0].key : null
+ initialSelectedKey ? initialSelectedKey : variantItems?.[0]?.key ?? null
);
if (!variantItems || variantItems.length < 1) {
@@ -146,6 +147,7 @@ const VariantManagement: FC = forwardRef(
},
[handleCancelButtonClick, closeOnItemSelect, selectedKey, variantItems, setSelectedKey]
);
+ const passThroughProps = usePassThroughHtmlProps(props);
return (
= forwardRef(
className={className}
style={style}
tooltip={tooltip}
+ {...passThroughProps}
>
{variantItems.map((item) => (
diff --git a/shared/tests/utils.tsx b/shared/tests/utils.tsx
index 313426d537c..c491424ba39 100644
--- a/shared/tests/utils.tsx
+++ b/shared/tests/utils.tsx
@@ -1,7 +1,7 @@
import { Event } from '@ui5/webcomponents-react-base/lib/Event';
import { ThemeProvider } from '@ui5/webcomponents-react/lib/ThemeProvider';
import { mount, shallow } from 'enzyme';
-import React from 'react';
+import React, { ComponentType } from 'react';
export const modifyObjectProperty = (object: any, attr: string, value: any) => {
Object.defineProperty(object, attr, {
@@ -30,3 +30,26 @@ export const mountThemedComponent = (
export const renderThemedComponent = (component, contextOverwrite = {}) =>
shallow({component}).render();
+
+export const createPassThroughPropsTest = (Component: ComponentType, props = {}) => {
+ test('Pass Through HTML Standard Props', () => {
+ const wrapper = mountThemedComponent(
+
+ );
+ const html = wrapper.html();
+
+ expect(html).toMatch(/data-special-test-prop="data-prop"/);
+ expect(html).toMatch(/aria-labelledby="aria-prop"/);
+ // special handling for ObjectPage Sections because of own ID handling...
+ if (Component.displayName !== 'ObjectPageSection' && Component.displayName !== 'ObjectPageSubSection') {
+ expect(html).toMatch(/id="element-id"/);
+ }
+ expect(html).not.toMatch(/disabled-custom-prop/);
+ });
+};