Skip to content

Forms: Fix "Other" toggle not updating option label in editor#47316

Merged
vianasw merged 2 commits intotrunkfrom
fix/forms-other-option-label-reset
Feb 25, 2026
Merged

Forms: Fix "Other" toggle not updating option label in editor#47316
vianasw merged 2 commits intotrunkfrom
fix/forms-other-option-label-reset

Conversation

@vianasw
Copy link
Contributor

@vianasw vianasw commented Feb 25, 2026

Follow-up of #46461 (fixes some regressions)

Proposed changes:

  • Fix the per-option sidebar "Other" toggle to clear the existing label when toggled on, so the "Other" placeholder text takes effect (matching the behavior of the parent-level "Include Other option" toggle which creates blocks with label: 'Other').
  • Use the dynamic placeholderValue (which switches between "Other" and "Add option…" based on isOther) for the non-standalone RichText placeholder, instead of a hardcoded "Add option…" string.

Other information:

  • Have you written new tests for your changes, if applicable?
  • Have you checked the E2E test CI results, and verified that your changes do not break them?
  • Have you tested your changes on WordPress.com, if applicable (if so, you'll see a generated comment below with a script to run)?

Jetpack product discussion

Does this pull request change what data or activity we track or use?

No.

Testing instructions:

  • Open a post with a Jetpack Form containing a Single Choice (radio) field with at least one option
  • Select a radio option that has a label (e.g., type "Option B")
  • In the block sidebar, toggle "Other" option ON
  • Verify the label changes to show "Other" (placeholder text) and a "Please specify…" text input appears below
  • Toggle "Other" option OFF and verify the label reverts to the "Add option…" placeholder
  • Also test the parent-level "Include Other option" toggle (on the Single Choice field itself) to confirm it still works as before

Changelog

  • Generate changelog entries for this PR (using AI).

vianasw and others added 2 commits February 25, 2026 12:27
When toggling "Other" on via the per-option sidebar control, only
isOther was set — the existing label was left unchanged, so an option
labeled "Option B" would visually remain "Option B" despite being
an "Other" option. Now the label is cleared when toggling on, letting
the "Other" placeholder text take effect (matching the behavior of the
parent-level "Include Other option" toggle).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings February 25, 2026 11:39
@github-actions
Copy link
Contributor

github-actions bot commented Feb 25, 2026

Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.

  • To test on WoA, go to the Plugins menu on a WoA dev site. Click on the "Upload" button and follow the upgrade flow to be able to upload, install, and activate the Jetpack Beta plugin. Once the plugin is active, go to Jetpack > Jetpack Beta, select your plugin (Jetpack), and enable the fix/forms-other-option-label-reset branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack fix/forms-other-option-label-reset

Interested in more tips and information?

  • In your local development environment, use the jetpack rsync command to sync your changes to a WoA dev blog.
  • Read more about our development workflow here: PCYsg-eg0-p2
  • Figure out when your changes will be shipped to customers here: PCYsg-eg5-p2

@github-actions
Copy link
Contributor

github-actions bot commented Feb 25, 2026

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ Add a "[Status]" label (In Progress, Needs Review, ...).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖


Follow this PR Review Process:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Make sure to test your changes on all platforms that it applies to. You're responsible for the quality of the code you ship.
  3. You can use GitHub's Reviewers functionality to request a review.
  4. When it's reviewed and merged, you will be pinged in Slack to deploy the changes to WordPress.com simple once the build is done.

If you have questions about anything, reach out in #jetpack-developers for guidance!

@github-actions github-actions bot added the [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. label Feb 25, 2026
@vianasw vianasw added the [Status] Needs Review This PR is ready for review. label Feb 25, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the Jetpack Forms option block editor behavior so “Other” radio options display the correct label/placeholder when toggled in the block sidebar.

Changes:

  • Clear the option label when enabling the per-option "Other" option toggle so the placeholder can display.
  • Use the computed placeholderValue for the non-standalone RichText placeholder (instead of a hardcoded Add option…).
  • Add a patch changelog entry documenting the fix.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
projects/packages/forms/src/blocks/option/edit.js Updates “Other” toggle handling and ensures the editor uses the dynamic placeholder for option labels.
projects/packages/forms/changelog/fix-forms-other-option-label-reset Adds a patch-level changelog entry for the editor fix.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +154 to +159
onChange={ value =>
setAttributes( {
isOther: value,
label: value ? '' : label,
} )
}
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.
@jp-launch-control
Copy link

Code Coverage Summary

This PR did not change code coverage!

That could be good or bad, depending on the situation. Everything covered before, and still is? Great! Nothing was covered before? Not so great. 🤷

Full summary · PHP report · JS report

@vianasw vianasw removed the [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. label Feb 25, 2026
@vianasw vianasw merged commit 51ca1f5 into trunk Feb 25, 2026
81 checks passed
@vianasw vianasw deleted the fix/forms-other-option-label-reset branch February 25, 2026 12:13
@github-actions github-actions bot removed the [Status] Needs Review This PR is ready for review. label Feb 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants