♻️ Add a “name” prop to every CheckboxGroup

This commit is contained in:
Philipp Stracker 2025-01-27 18:54:02 +01:00
parent dd454d4d12
commit 94069238f3
No known key found for this signature in database
4 changed files with 13 additions and 4 deletions

View file

@ -49,7 +49,7 @@ const LocationSelector = ( { location, setLocation } ) => {
) }
</SelectStylingSection>
<CheckboxStylingSection
className="location-activation"
name="location-activation"
separatorAndGap={ false }
options={ [ activateCheckbox ] }
value={ isActive }

View file

@ -9,8 +9,8 @@ const SectionPaymentMethods = ( { location } ) => {
return (
<CheckboxStylingSection
name="payment-methods"
title={ __( 'Payment Methods', 'woocommerce-paypal-payments' ) }
className="payment-methods"
options={ choices }
value={ paymentMethods }
onChange={ setPaymentMethods }

View file

@ -21,7 +21,7 @@ const SectionTagline = ( { location } ) => {
return (
<CheckboxStylingSection
className="tagline"
name="tagline"
separatorAndGap={ false }
options={ [ checkbox ] }
value={ tagline }

View file

@ -6,6 +6,7 @@ import StylingSection from './StylingSection';
const StylingSectionWithCheckboxes = ( {
title,
name,
className = '',
description = '',
separatorAndGap = true,
@ -14,7 +15,14 @@ const StylingSectionWithCheckboxes = ( {
onChange,
children,
} ) => {
className = classNames( 'ppcp--has-checkboxes', className );
className = classNames( 'ppcp--has-checkboxes', name, className );
if ( ! name ) {
console.error(
'Checkbox sections need a unique name! No name given to:',
title
);
}
return (
<StylingSection
@ -25,6 +33,7 @@ const StylingSectionWithCheckboxes = ( {
>
<VStack spacing={ 6 }>
<CheckboxGroup
name={ name }
options={ options }
value={ value }
onChange={ onChange }