Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/tabbed-posts-preview-category-fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@devgateway/dvz-ui-react": patch
---

Fix TCDICORE-601: the Gutenberg block editor's live preview for Tabbed Posts (and other blocks with array attributes such as `categories`) sent array attribute values to the preview iframe as JSON-stringified arrays (e.g. `"[5,7]"`), while the published front end joins them as comma-separated strings (`"5,7"`). The mismatch produced malformed REST query parameters (`&category=[5,7]`) that WordPress could not parse, so the live preview showed incorrectly-filtered posts even though the published page rendered correctly. Array attributes are now comma-joined in `PreviewComponent.tsx` to match the front-end save format; non-array object attributes are unaffected.
4 changes: 3 additions & 1 deletion packages/dvz-ui/src/layout/PreviewComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ const PreviewComponentParameterParser = () => {
const newParams: Record<string, string> = { ...paramPropsRef.current };
Object.keys(data).forEach(k => {
newParams["data-" + k.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase()] =
typeof data[k] === 'object' ? JSON.stringify(data[k]) : data[k];
typeof data[k] === 'object'
? (Array.isArray(data[k]) ? data[k].join(',') : JSON.stringify(data[k]))
: data[k];
Comment on lines 30 to +33
});
setParamProps(newParams);
}
Expand Down
Loading