Skip to content

Commit 0e57467

Browse files
fix: prevent color picker popup from closing on icon color change
1 parent a523f00 commit 0e57467

1 file changed

Lines changed: 34 additions & 34 deletions

File tree

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', {

0 commit comments

Comments
 (0)