Make WordPress Core

#57903 closed defect (bug) (fixed)

Non-core blocks are not properly loading RTL stylesheets

Reported by: davidbinda's profile david.binda Owned by: sergeybiryukov's profile SergeyBiryukov
Milestone: 6.2.1 Priority: normal
Severity: normal Version: 6.1.1
Component: Editor Keywords: has-patch fixed-major
Focuses: css, rtl Cc:

Description

This is a follow-up to #56325 where an issue for core-blocks has been reported. There's also #56797 which adds PHPUnit tests for RTL stylesheets loading, however the current logic introduced in r54330 only works in a situation when the SCRIPT_DEBUG is defined and set to true (which is the case during the PHPUnit tests being run).

When the SCRIPT_DEBUG is set to false, the -rtl styles for non-core blocks are not being loaded.

To reproduce the issue, I used the blocks-non-jsx/02-stylesheets block of the gutenberg examples repository and added a modified style-rtl.css file to the block.

On a site in one of the RTL languages, I added the block to a post and it can be seen on a frontend that the style-rtl.css is only loaded when the SCRIPT_DEBUG is set to true.

The bug seems to be due to the fact that core blocks' styles are being loaded with `.min` suffix, while non-core ones are never using the minified files, but the suffix is always being taken into consideration when the -rtl file lookup is performed.

Attachments (1)

57903.diff (706 bytes) - added by david.binda 21 months ago.

Download all attachments as: .zip

Change History (8)

@david.binda
21 months ago

#1 @krupalpanchal
21 months ago

  • Keywords has-patch added

#2 @SergeyBiryukov
21 months ago

  • Milestone changed from Awaiting Review to 6.2.1

Thanks for the ticket and the patch!

Moving for 6.2.1 consideration, as it's not a regression in 6.2 but should be fixed sooner rather than later.

#3 @SergeyBiryukov
21 months ago

It's not immediate clear to me how to add a unit test for this change, as reproducing the issue requires SCRIPT_DEBUG to be set to false, and it is already set to true when the test suite is run. That said, I've double-checked the logic and it looks correct to me.

#4 @SergeyBiryukov
21 months ago

  • Owner set to SergeyBiryukov
  • Resolution set to fixed
  • Status changed from new to closed

In 55544:

Editor: Correctly load RTL stylesheets for non-core blocks.

If SCRIPT_DEBUG is disabled, register_block_style_handle() loads core blocks' styles with the .min suffix, while non-core ones never use the minified files, but the suffix was still mistakenly included in the -rtl file lookup.

This commit updates the logic to match the style path set earlier in the function, ensuring that RTL stylesheets are loaded properly for both core and non-core blocks, with or without SCRIPT_DEBUG.

Follow-up to [49982], [50836], [54330], [55486].

Props david.binda.
Fixes #57903.

#5 @SergeyBiryukov
21 months ago

  • Keywords fixed-major added
  • Resolution fixed deleted
  • Status changed from closed to reopened

Reopening for 6.2.1 consideration.

#6 @SergeyBiryukov
21 months ago

In 55547:

Coding Standards: Use single quotes for strings without variables in register_block_style_handle().

This resolves two WPCS errors:

String ".css" does not require double quotes; use single quotes instead
String "-rtl.css" does not require double quotes; use single quotes instead

Follow-up to [55544].

See #57903.

#7 @SergeyBiryukov
20 months ago

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

In 55635:

Editor: Correctly load RTL stylesheets for non-core blocks.

If SCRIPT_DEBUG is disabled, register_block_style_handle() loads core blocks' styles with the .min suffix, while non-core ones never use the minified files, but the suffix was still mistakenly included in the -rtl file lookup.

This commit updates the logic to match the style path set earlier in the function, ensuring that RTL stylesheets are loaded properly for both core and non-core blocks, with or without SCRIPT_DEBUG.

Follow-up to [49982], [50836], [54330], [55486].

Props david.binda.
Merges [55544] and [55547] to the 6.2 branch.
Fixes #57903.

Note: See TracTickets for help on using tickets.