Skip to content

Commit 6be09f1

Browse files
committed
Reset groups visibility on list change.
1 parent 33fe00b commit 6be09f1

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

includes/blocks/mailchimp/edit.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,17 @@ export const BlockEdit = (props) => {
104104
}),
105105
);
106106
replaceInnerBlocks(clientId, [...listInnerBlocks], false);
107+
108+
// Reset groups visibility settings on list change.
109+
if (data?.interest_groups?.length > 0) {
110+
const newVisibility = data?.interest_groups?.reduce((acc, field) => {
111+
acc[field.id] = 'off';
112+
return acc;
113+
}, {});
114+
setAttributes({ interest_groups_visibility: newVisibility });
115+
} else {
116+
setAttributes({ interest_groups_visibility: {} });
117+
}
107118
} else if (exisingTags && exisingTags.length > 0) {
108119
// Update existing innerBlocks with if new fields are added to the list or removed from the list.
109120
const newFormFields = data?.merge_fields?.filter(

0 commit comments

Comments
 (0)