Skip to content

Commit ce98b8c

Browse files
authored
Sync branch [skip ci]
2 parents 6e286e0 + d2e74a6 commit ce98b8c

File tree

3 files changed

+36
-35
lines changed

3 files changed

+36
-35
lines changed

assets/apps/customizer-controls/src/repeater/Repeater.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ const Repeater = ({
4444
for (const [field] of Object.entries(itemFields)) {
4545
newItem.visibility = 'yes';
4646

47-
if (typeof value[0][field] === 'boolean') {
47+
if (typeof value[0]?.[field] === 'boolean') {
4848
newItem[field] = true;
4949
if (field === 'hide_on_mobile') {
5050
newItem[field] = false;

assets/apps/customizer-controls/src/repeater/RepeaterItemContent.js

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,40 @@ const RepeaterItemContent = ({
169169
/>
170170
);
171171
case 'switcher':
172-
return <Switcher fieldId={key} currentField={currentField} />;
172+
const selectedOption =
173+
value[index][key] || Object.keys(currentField.options)[0];
174+
175+
return (
176+
<>
177+
<ButtonGroup className="neve-background-type-control">
178+
{Object.entries(currentField.options).map(
179+
([optionKey, option]) => {
180+
return (
181+
<Button
182+
key={optionKey}
183+
isPrimary={
184+
optionKey === selectedOption
185+
}
186+
isSecondary={
187+
optionKey !== selectedOption
188+
}
189+
onClick={() => {
190+
changeContent(key, optionKey);
191+
}}
192+
>
193+
{option.label}
194+
</Button>
195+
);
196+
}
197+
)}
198+
</ButtonGroup>
199+
{currentField.options?.[selectedOption]?.fields.map(
200+
(componentId) => {
201+
return toComponent(componentId, value[index]);
202+
}
203+
)}
204+
</>
205+
);
173206
case 'media':
174207
return (
175208
<Placeholder
@@ -217,39 +250,6 @@ const RepeaterItemContent = ({
217250
}
218251
};
219252

220-
const Switcher = ({ fieldId, currentField }) => {
221-
const selectedOption =
222-
value[index][fieldId] || Object.keys(currentField.options)[0];
223-
224-
return (
225-
<>
226-
<ButtonGroup className="neve-background-type-control">
227-
{Object.entries(currentField.options).map(
228-
([optionKey, option]) => {
229-
return (
230-
<Button
231-
key={optionKey}
232-
isPrimary={optionKey === selectedOption}
233-
isSecondary={optionKey !== selectedOption}
234-
onClick={() => {
235-
changeContent(fieldId, optionKey);
236-
}}
237-
>
238-
{option.label}
239-
</Button>
240-
);
241-
}
242-
)}
243-
</ButtonGroup>
244-
{currentField.options?.[selectedOption]?.fields.map(
245-
(componentId) => {
246-
return toComponent(componentId, value[index]);
247-
}
248-
)}
249-
</>
250-
);
251-
};
252-
253253
return (
254254
<div
255255
className={classNames('sortable-subcontrols', {

globals/sanitize-functions.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,7 @@ function neve_sanitize_meta_repeater( $value ) {
346346
'field',
347347
'format',
348348
'fallback',
349+
'__kbKey',
349350
];
350351

351352
if ( empty( $value ) ) {

0 commit comments

Comments
 (0)