Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fixed

Fix "Other" option toggle not updating the option label in the editor
9 changes: 7 additions & 2 deletions projects/packages/forms/src/blocks/option/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,12 @@ const OptionEdit = ( {
<ToggleControl
label={ __( '"Other" option', 'jetpack-forms' ) }
checked={ !! isOther }
onChange={ value => setAttributes( { isOther: value } ) }
onChange={ value =>
setAttributes( {
isOther: value,
label: value ? '' : label,
} )
}
Comment on lines +154 to +159
Copy link

Copilot AI Feb 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Toggling isOther on clears label, but it doesn’t adjust the placeholder attribute. If this block instance has a non-empty placeholder (many option blocks are created/migrated with placeholder: 'Add option…'), then placeholderValue will remain 'Add option…' even when isOther is true, so the option won’t display the expected “Other” label in the editor. Consider making the “Other” placeholder take precedence when isOther is enabled (e.g., set placeholder to '' or to the translated “Other” value when toggling on, or change the placeholderValue logic to ignore the default add-option placeholder when isOther is true).

Suggested change
onChange={ value =>
setAttributes( {
isOther: value,
label: value ? '' : label,
} )
}
onChange={ value => {
const newAttributes = {
isOther: value,
label: value ? '' : label,
};
if ( value ) {
newAttributes.placeholder = __( 'Other', 'jetpack-forms' );
}
setAttributes( newAttributes );
} }

Copilot uses AI. Check for mistakes.
help={ __(
'Show as "Other" option with a text input field below it.',
'jetpack-forms'
Expand All @@ -169,7 +174,7 @@ const OptionEdit = ( {
tagName="div"
className="wp-block"
value={ labelValue }
placeholder={ __( 'Add option…', 'jetpack-forms' ) }
placeholder={ placeholderValue }
__unstableDisableFormats
onChange={ newLabel => setAttributes( { label: newLabel } ) }
onMerge={ mergeBlocks }
Expand Down
Loading