Skip to content

Replace global experiments checkbox with enable/disable button#168

Merged
dkotter merged 12 commits intoWordPress:developfrom
Omcodes23:develop
Feb 4, 2026
Merged

Replace global experiments checkbox with enable/disable button#168
dkotter merged 12 commits intoWordPress:developfrom
Omcodes23:develop

Conversation

@Omcodes23
Copy link
Contributor

@Omcodes23 Omcodes23 commented Jan 9, 2026

What?

Closes #157

Replace the global experiments checkbox with an enable/disable button that auto-submits the settings form, reducing the number of actions needed to enable experiments from 4 to 3.

Why?

Currently, enabling AI Experiments requires:

  1. Check the "Enable Experiments" checkbox
  2. Click "Save Changes"
  3. Check an individual experiment checkbox
  4. Click "Save Changes" again

By replacing the global checkbox with a button that auto-submits, we reduce this to:

  1. Click "Enable Experiments" button (auto-saves)
  2. Check an individual experiment checkbox
  3. Click "Save Changes"

This improves the user experience by making the global toggle more intuitive and reducing friction.

How?

  • Replaced the "Enable Experiments" checkbox with a button that changes based on state:
    • When disabled: "Enable Experiments" with primary (blue) styling
    • When enabled: "Disable Experiments" with secondary (grey) styling
  • Button uses a hidden input field to store the toggle state value
  • Added inline JavaScript that updates the hidden field value and auto-submits the form on button click
  • Added helper text below the button to clarify that clicking saves immediately
  • Updated SCSS to support the new button-based toggle layout with flex-wrap
  • Preserved the "Save Changes" button at the bottom of the page for individual experiment settings
  • Updated E2E test helpers to work with the new button-based UI (click button instead of checkbox)

Testing Instructions

  1. Navigate to Settings > AI Experiments (ensure you have valid AI credentials configured)
  2. Verify the page shows "Enable Experiments" button with primary (blue) styling
  3. Click the "Enable Experiments" button
  4. Page should reload automatically with "Settings saved" success notice
  5. Verify the button now shows "Disable Experiments" with secondary (grey) styling
  6. Verify individual experiments are now enabled and can be toggled
  7. Verify the "Save Changes" button at the bottom still works for individual experiment changes
  8. Click "Disable Experiments" button
  9. Page should reload with "Settings saved" success notice
  10. Verify the button is back to "Enable Experiments" with primary styling
  11. Verify individual experiments are disabled (greyed out)

Testing Instructions for Keyboard

  1. Navigate to Settings > AI Experiments using keyboard (Tab)
  2. Tab to the "Enable Experiments" button
  3. Press Enter or Space to activate the button
  4. After page reload, verify button text changed to "Disable Experiments"
  5. Tab to individual experiment checkboxes and verify they are now focusable and editable
  6. Tab to "Disable Experiments" button and press Enter or Space
  7. After page reload, verify button text changed back to "Enable Experiments"
  8. Verify all interactive elements maintain proper focus order and visual focus indicators

Screenshots or screencast

Before After
Checkbox labeled "Enable Experiments" with separate "Save Changes" button required "Enable Experiments" button (primary styling) that auto-saves when clicked
After checking: Same checkbox UI, manual save needed After clicking: "Disable Experiments" button (secondary styling) with helper text explaining immediate save
Open WordPress Playground Preview

- Replace Enable Experiments checkbox with button that auto-submits
- Button text and styling changes based on state (Enable/Disable)
- Primary button styling when disabled, secondary when enabled
- Add helper text to clarify immediate save behavior
- Update SCSS to support new button-based toggle layout
- Preserve Save Changes button for other settings

Fixes WordPress#157
@github-actions
Copy link

github-actions bot commented Jan 9, 2026

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: Omcodes23 <omcodes23@git.wordpress.org>
Co-authored-by: jeffpaul <jeffpaul@git.wordpress.org>
Co-authored-by: dkotter <dkotter@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@codecov
Copy link

codecov bot commented Jan 9, 2026

Codecov Report

❌ Patch coverage is 0% with 25 lines in your changes missing coverage. Please review.
✅ Project coverage is 50.45%. Comparing base (965498c) to head (6e60327).
⚠️ Report is 14 commits behind head on develop.

Files with missing lines Patch % Lines
includes/Settings/Settings_Page.php 0.00% 25 Missing ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##             develop     #168      +/-   ##
=============================================
- Coverage      50.80%   50.45%   -0.36%     
- Complexity       375      379       +4     
=============================================
  Files             27       27              
  Lines           1978     1992      +14     
=============================================
  Hits            1005     1005              
- Misses           973      987      +14     
Flag Coverage Δ
unit 50.45% <0.00%> (-0.36%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@jeffpaul jeffpaul added this to the 0.3.0 milestone Jan 9, 2026
@jeffpaul jeffpaul requested a review from dkotter January 9, 2026 19:35
Copy link
Collaborator

@dkotter dkotter left a comment

Choose a reason for hiding this comment

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

Overall this looks okay to me though we'll want to ensure this works fine with the changes in #153.

In addition, there are E2E failures here that will need fixed up before we merge this in

Omcodes23 and others added 5 commits January 13, 2026 16:58
- Update enableExperiments to click button instead of checkbox
- Update disableExperiments to click button instead of checkbox
- Use button selector with :has-text() for reliability
- Add page reload wait for auto-submit behavior
- Use simple class selector 'button.ai-experiments__toggle-button' instead of :has-text()
- Add waitForSelector to ensure button exists before clicking
- Use develop to get all buttons and click the first one
- Fix prettier linting by avoiding complex selectors on single line
Add spaces around array index: buttons[0] -> buttons[ 0 ]
@Omcodes23
Copy link
Contributor Author

@dkotter Now Works ?

@Omcodes23
Copy link
Contributor Author

@dkotter @jeffpaul any updates ?

@jeffpaul
Copy link
Member

@Omcodes23 we're working to wrap up work on version 0.2.0, we'll get to this next as we start to work on 0.3.0.

@dkotter dkotter merged commit 2d80b12 into WordPress:develop Feb 4, 2026
22 of 24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update Settings > AI Experiments enablement from checkbox to button

3 participants