Make WordPress Core

Opened 10 months ago

Closed 10 months ago

Last modified 10 months ago

#58605 closed defect (bug) (fixed)

Core block editor styles registered with frontend stylesheet URL instead of editor stylesheet URL

Reported by: flixos90's profile flixos90 Owned by: flixos90's profile flixos90
Milestone: 6.3 Priority: normal
Severity: normal Version:
Component: Editor Keywords: has-patch has-unit-tests
Focuses: Cc:

Description

While taking a closer look at the register_block_style_handle() function for #58528, I noticed that all core block editor style handles (i.e. wp-block-{$block_name}-editor) are registered pointing to the frontend stylesheet (style.css) rather than the editor stylesheet (editor.css). This happens because the style.css file name is hard-coded in the function regardless of whether the style or editorStyle is being registered.

Effectively, right now every pair of wp-block-{$block_name} and wp-block-{$block_name}-editor handles uses the same stylesheet file, which looks wrong given that several of them have dedicated editor stylesheets.

Looking at the Gutenberg plugin, it appears to work correctly there since Gutenberg has a dedicated logic path for editor styles, see https://github.com/WordPress/gutenberg/blob/3a419b840da0117ea05925c994861919acbe0c3d/lib/blocks.php#L277. So this is specifically a WordPress core bug that we should fix.

Adding this to the 6.3 milestone for consideration.

Change History (5)

This ticket was mentioned in Slack in #core-editor by flixos90. View the logs.


10 months ago

This ticket was mentioned in PR #4679 on WordPress/wordpress-develop by @flixos90.


10 months ago
#2

  • Keywords has-patch has-unit-tests added; needs-patch removed

Trac ticket: https://core.trac.wordpress.org/ticket/58605

This PR also includes test coverage for the core-specific code paths of register_block_style_handle() which was missing before.

#3 @flixos90
10 months ago

  • Owner set to flixos90
  • Status changed from new to assigned

PR https://github.com/WordPress/wordpress-develop/pull/4679 is ready for review.

It fixes the bug and adds test coverage for the core block-specific behavior, which was missing before. The tests ensure that the bug is fixed as intended.

#4 @flixos90
10 months ago

  • Resolution set to fixed
  • Status changed from assigned to closed

In 56005:

Editor: Fix block editor styles being registered with frontend stylesheets.

This changeset fixes a bug where WordPress core's own block editor styles (wp-block-{$block_name}-editor) were referencing the same CSS files as their frontend equivalents (wp-block-{$block_name}). This would result in incorrect frontend styles potentially being loaded in the block editor.

Tests for the related logic have been added.

Props flixos90, joemcgill, mukesh27, spacedmonkey.
Fixes #58605.

Note: See TracTickets for help on using tickets.