From 69f9011b5f0fbf51fd50e9d8bdbdbf3521f5cf22 Mon Sep 17 00:00:00 2001 From: Ruslan Matkovskyi Date: Wed, 4 Jan 2023 18:05:31 +0100 Subject: [PATCH] #559044: fixed rendering dynamic placeholder --- .../src/components/PlaceholderCommon.tsx | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/packages/sitecore-jss-react/src/components/PlaceholderCommon.tsx b/packages/sitecore-jss-react/src/components/PlaceholderCommon.tsx index ff28cb83f8..70e17d4f83 100644 --- a/packages/sitecore-jss-react/src/components/PlaceholderCommon.tsx +++ b/packages/sitecore-jss-react/src/components/PlaceholderCommon.tsx @@ -12,9 +12,6 @@ import { import { convertAttributesToReactProps } from '../utils'; import { HiddenRendering, HIDDEN_RENDERING_NAME } from './HiddenRendering'; -/** [SXA] common marker by which we find container fo replacing **/ -const PREFIX_PLACEHOLDER = 'container-{*}'; - type ErrorComponentProps = { [prop: string]: unknown; }; @@ -122,9 +119,13 @@ export class PlaceholderCommon extends React.Compone let result; /** [SXA] it needs for deleting dynamics placeholder when we set him number(props.name) of container. from backend side we get common name of placeholder is called 'container-{*}' where '{*}' marker for replacing **/ - if (rendering && rendering.placeholders && rendering.placeholders[PREFIX_PLACEHOLDER]) { - rendering.placeholders[name] = rendering.placeholders[PREFIX_PLACEHOLDER]; - delete rendering.placeholders[PREFIX_PLACEHOLDER]; + if (rendering && rendering.placeholders) { + Object.keys(rendering.placeholders).forEach((placeholder) => { + if (placeholder.indexOf('{*}') !== -1) { + rendering.placeholders[name] = rendering.placeholders[placeholder]; + delete rendering.placeholders[placeholder]; + } + }); } if (rendering && rendering.placeholders && Object.keys(rendering.placeholders).length > 0) {