Skip to content

Gutenberg Experiments: Ensure the experiment is active before outputting flags#77728

Merged
andrewserong merged 1 commit into
trunkfrom
fix/gutenberg-experiments-accidentally-enabled-when-should-be-false
Apr 28, 2026
Merged

Gutenberg Experiments: Ensure the experiment is active before outputting flags#77728
andrewserong merged 1 commit into
trunkfrom
fix/gutenberg-experiments-accidentally-enabled-when-should-be-false

Conversation

@andrewserong
Copy link
Copy Markdown
Contributor

What?

Follows:

Ensure that Gutenberg experiments are actually active and truthy before outputting their JS global flags.

Why?

In #77443 where the experiments page was redesigned, switching an experiment to be off now means that the flag is set to false explicitly. Many of the experiments only checked to see if the array key exists, and so if the key existed but was set to false the experiment would unexpectedly be active 😱

This change updates all the experiments that were doing that to use the gutenberg_is_experiment_enabled utility function that performs a ! empty() check which means explicit false values will be treated as the experiment not being enabled.

How?

  • Update the enable experiments code to use the gutenberg_is_experiment_enabled check instead of an array key exists check

Testing Instructions

  • In trunk try toggling the Media Upload Modal on and off and notice that after activating it's impossible to switch off
  • With this PR applied, toggling should work as expected
  • Double-check each of the experiments updated here to make sure they're all toggling as expected

Screenshots or screencast

To show what I mean, toggle this experiment on and off at http://localhost:8888/wp-admin/admin.php?page=experiments-wp-admin:

image

Then go to the post editor and go to add a featured image, and you should see the core media modal:

image

And not this one, which should only show if the experiment is on:

image

Use of AI Tools

Claude Code

@andrewserong andrewserong self-assigned this Apr 28, 2026
@andrewserong andrewserong added the [Type] Bug An existing feature does not function as intended label Apr 28, 2026
@andrewserong andrewserong added the Gutenberg Plugin Issues or PRs related to Gutenberg Plugin management related efforts label Apr 28, 2026
Copy link
Copy Markdown
Member

@ramonjd ramonjd left a comment

Choose a reason for hiding this comment

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

I checked the affected experiments that run clientside, e.g., upload modal and experimental blocks.

This PR ensures that toggling on/off works (they are off)
Toggling back on activates the experiments too.

Good spotting @andrewserong

@github-actions
Copy link
Copy Markdown

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: andrewserong <andrewserong@git.wordpress.org>
Co-authored-by: ramonjd <ramonopoly@git.wordpress.org>

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

@andrewserong
Copy link
Copy Markdown
Contributor Author

Thanks for the quick review! 🙇

@andrewserong andrewserong enabled auto-merge (squash) April 28, 2026 01:31
@github-actions
Copy link
Copy Markdown

Flaky tests detected in 30164c4.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/25028630141
📝 Reported issues:

@andrewserong andrewserong merged commit 264ba7b into trunk Apr 28, 2026
50 of 51 checks passed
@andrewserong andrewserong deleted the fix/gutenberg-experiments-accidentally-enabled-when-should-be-false branch April 28, 2026 02:05
@github-actions github-actions Bot added this to the Gutenberg 23.1 milestone Apr 28, 2026
@t-hamano
Copy link
Copy Markdown
Contributor

Thanks for the follow-up 🙇‍♂️

t-hamano pushed a commit that referenced this pull request Apr 29, 2026
…ing flags (#77728)

Co-authored-by: andrewserong <andrewserong@git.wordpress.org>
Co-authored-by: ramonjd <ramonopoly@git.wordpress.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Gutenberg Plugin Issues or PRs related to Gutenberg Plugin management related efforts [Type] Bug An existing feature does not function as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants