Skip to content

Commit

Permalink
#559044: fixed rendering dynamic placeholder
Browse files Browse the repository at this point in the history
  • Loading branch information
sc-ruslanmatkovskyi committed Jan 4, 2023
1 parent 8b8d227 commit 69f9011
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions packages/sitecore-jss-react/src/components/PlaceholderCommon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand Down Expand Up @@ -122,9 +119,13 @@ export class PlaceholderCommon<T extends PlaceholderProps> 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) {
Expand Down

0 comments on commit 69f9011

Please sign in to comment.