Skip to content

Fix: Disable Custom CSS command for non block themes#77685

Merged
t-hamano merged 2 commits intoWordPress:trunkfrom
DarkMatter-999:fix/custom-css-command-pallete
Apr 28, 2026
Merged

Fix: Disable Custom CSS command for non block themes#77685
t-hamano merged 2 commits intoWordPress:trunkfrom
DarkMatter-999:fix/custom-css-command-pallete

Conversation

@DarkMatter-999
Copy link
Copy Markdown
Contributor

What?

Closes #73408

Hide the "Open Custom CSS" command from the Command Palette when the active theme is not a block theme.

Why?

The "Open Custom CSS" command is currently available when using hybrid themes (themes with theme.json but not full block themes). However, invoking this command navigates to the Site Editor and results in an error:

"You attempted to edit an item that doesn't exist. Perhaps it was deleted?"

This happens because custom CSS editing via Global Styles is only supported for block themes. Hybrid themes may expose partial data, which causes the command to appear even though the feature is not actually usable.

This leads to a broken user experience where users can access a command that always fails.

How?

This PR adds an additional guard to the command registration logic:

  • Uses getCurrentTheme() from the core store to determine whether the active theme is a block theme (is_block_theme)
  • Ensures the "Open Custom CSS" command is only registered when the active theme is a block theme (isBlockBasedTheme)

Testing Instructions

  1. Use a site with a hybrid theme (classic theme with theme.json, but not a block theme)
  2. Open the Command Palette
  3. Search for "Custom CSS"

Expected:

  • The command should not appear
  1. Switch to a block theme
  2. Open the Command Palette again
  3. Search for "Custom CSS"

Expected:

  • The command appears
  • Clicking it opens the Global Styles CSS editor without errors

Screenshots or screencast

Before

custom-css-hybird-theme.mov

After

custom-css-fix.mov

Use of AI Tools

Drafted PR description with assistance from ChatGPT. The implementation and final PR content were reviewed and validated manually.

P.S.
An alternative approach could be to redirect users on hybrid and classic themes to the Customizer’s "Additional CSS" panel instead of hiding the command entirely as in this previous PR(#65155). This would require confirming that the user has permission to edit theme options, which might be approximated in JS via:

select( 'core' ).canUser( 'update', 'themes' );

@DarkMatter-999 DarkMatter-999 marked this pull request as ready for review April 27, 2026 08:44
@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: DarkMatter-999 <lakshyajeet@git.wordpress.org>
Co-authored-by: t-hamano <wildworks@git.wordpress.org>
Co-authored-by: MadtownLems <madtownlems@git.wordpress.org>

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

@t-hamano t-hamano added the [Type] Bug An existing feature does not function as intended label Apr 27, 2026
Copy link
Copy Markdown
Contributor

@t-hamano t-hamano left a comment

Choose a reason for hiding this comment

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

LGTM! For now, this approach seems to be the simplest 👍

@t-hamano t-hamano merged commit cc4d9bf into WordPress:trunk Apr 28, 2026
49 of 50 checks passed
@github-actions github-actions Bot added this to the Gutenberg 23.1 milestone Apr 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] Core commands [Type] Bug An existing feature does not function as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"Custom CSS" in Command Palette for non-block themes

2 participants