diff --git a/assets/apps/customizer-controls/src/repeater/Repeater.js b/assets/apps/customizer-controls/src/repeater/Repeater.js index 66daf9663a..af0132dfcf 100644 --- a/assets/apps/customizer-controls/src/repeater/Repeater.js +++ b/assets/apps/customizer-controls/src/repeater/Repeater.js @@ -44,7 +44,7 @@ const Repeater = ({ for (const [field] of Object.entries(itemFields)) { newItem.visibility = 'yes'; - if (typeof value[0][field] === 'boolean') { + if (typeof value[0]?.[field] === 'boolean') { newItem[field] = true; if (field === 'hide_on_mobile') { newItem[field] = false; diff --git a/assets/apps/customizer-controls/src/repeater/RepeaterItemContent.js b/assets/apps/customizer-controls/src/repeater/RepeaterItemContent.js index 27d86f559f..0ec169a4fe 100644 --- a/assets/apps/customizer-controls/src/repeater/RepeaterItemContent.js +++ b/assets/apps/customizer-controls/src/repeater/RepeaterItemContent.js @@ -169,7 +169,40 @@ const RepeaterItemContent = ({ /> ); case 'switcher': - return ; + const selectedOption = + value[index][key] || Object.keys(currentField.options)[0]; + + return ( + <> + + {Object.entries(currentField.options).map( + ([optionKey, option]) => { + return ( + + ); + } + )} + + {currentField.options?.[selectedOption]?.fields.map( + (componentId) => { + return toComponent(componentId, value[index]); + } + )} + + ); case 'media': return ( { - const selectedOption = - value[index][fieldId] || Object.keys(currentField.options)[0]; - - return ( - <> - - {Object.entries(currentField.options).map( - ([optionKey, option]) => { - return ( - - ); - } - )} - - {currentField.options?.[selectedOption]?.fields.map( - (componentId) => { - return toComponent(componentId, value[index]); - } - )} - - ); - }; - return (