Skip to content

Commit 262c968

Browse files
authored
fix(integrations): normalize inbound option shape in configure view (#4717)
1 parent fa557ec commit 262c968

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

src/wizards/audience/views/integrations/configure-view.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,16 +144,21 @@ export const ConfigureView = ( { integrations, loading, pendingChanges, saving,
144144
<Grid columns={ 2 } gutter={ 32 } noMargin>
145145
<SectionHeader heading={ 2 } title={ __( 'Inbound', 'newspack-plugin' ) } noMargin />
146146
<Grid columns={ 1 } rowGap={ 8 } noMargin>
147-
{ ( inboundField.options || [] ).map( optionName => {
147+
{ ( inboundField.options || [] ).map( option => {
148+
// Framework injects options as { value, label } objects
149+
// (see class-integration.php:get_settings_config()), but accepts bare strings
150+
// for backward compatibility.
151+
const optionValue = typeof option === 'string' ? option : option.value;
152+
const optionLabel = typeof option === 'string' ? option : option.label || option.value;
148153
const currentValue = getFieldValue( inboundField );
149154
const selected = Array.isArray( currentValue ) ? currentValue : [];
150155
return (
151156
<CheckboxControl
152157
className="newspack-checkbox-control"
153-
key={ optionName }
154-
label={ optionName }
155-
checked={ selected.includes( optionName ) }
156-
onChange={ checked => handleCheckboxListChange( inboundField.key, currentValue, optionName, checked ) }
158+
key={ optionValue }
159+
label={ optionLabel }
160+
checked={ selected.includes( optionValue ) }
161+
onChange={ checked => handleCheckboxListChange( inboundField.key, currentValue, optionValue, checked ) }
157162
/>
158163
);
159164
} ) }

0 commit comments

Comments
 (0)