Skip to content

Commit 7cf6cad

Browse files
r0b1nDiljohnSinghAndries-Smit
committed
fix: an issue with key prop warning
Co-authored-by: Diljohn Singh <diljohn.chauhan@gmail.com> Co-authored-by: Andries Smit <mr.andries.smit@gmail.com>
1 parent f67d586 commit 7cf6cad

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

packages/pluggableWidgets/html-element-web/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66

77
## [Unreleased]
88

9+
### Fixed
10+
11+
- We fixed a warning related to non-unique "key" props that appeared in certain scenarios.
12+
913
## [1.2.2] - 2025-03-14
1014

1115
### Security

packages/pluggableWidgets/html-element-web/src/HTMLElement.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ export function HTMLElement(props: HTMLElementContainerProps): ReactElement | nu
2222

2323
return (
2424
<Fragment>
25-
{items.map(item => (
25+
{items.map((item, index) => (
2626
<HTMLTag
27-
key={item?.id}
27+
key={`${props.name}_${item?.id || index}`}
2828
tagName={tag as keyof JSX.IntrinsicElements}
2929
attributes={{
3030
...prepareAttributes(createAttributeResolver(item), props.attributes, props.class, props.style),

packages/pluggableWidgets/html-element-web/src/components/__tests__/HTMLTag.spec.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ describe("HTMLTag", () => {
3737
});
3838

3939
it("with innerHTML apply html sanitizing", () => {
40-
const checkSapshot = (html: string): void => {
40+
const checkSnapshot = (html: string): void => {
4141
expect(
4242
render(
4343
<HTMLTag
@@ -53,10 +53,10 @@ describe("HTMLTag", () => {
5353
).toMatchSnapshot();
5454
};
5555

56-
checkSapshot("<p>Lorem ipsum <script>alert(1)</script></p>");
57-
checkSapshot("<img src=x onerror=alert(1)>");
58-
checkSapshot(`<b onmouseover=alert(‘XSS testing!‘)>ok</b>`);
59-
checkSapshot("<a>123</a><option><style><img src=x onerror=alert(1)></style>");
56+
checkSnapshot("<p>Lorem ipsum <script>alert(1)</script></p>");
57+
checkSnapshot("<img src=x onerror=alert(1)>");
58+
checkSnapshot(`<b onmouseover=alert(‘XSS testing!‘)>ok</b>`);
59+
checkSnapshot("<a>123</a><option><style><img src=x onerror=alert(1)></style>");
6060
});
6161

6262
it("fires events", async () => {

0 commit comments

Comments
 (0)