Developer checks WordPress CSS module collisions between bundled interface components on a desktop monitor Developer checks WordPress CSS module collisions between bundled interface components on a desktop monitor

WordPress CSS Module Collisions: Plugin Fixes for 7.2

A November 16 WordPress Core dev note explains how bundled package versions can share CSS module class names and gives plugin developers specific fixes ahead of WordPress 7.2. It also clarifies which collisions the update will not resolve.

A WordPress Core dev note published Monday, November 16, describes how plugins bundling different versions of WordPress packages can end up sharing CSS module class names. The collision can cause one copy’s styles to affect another copy’s components. For developers preparing for WordPress 7.2, the note lists package versions with the fix and a separate build-tool update.

Answer: If your plugin bundles any affected @wordpress/* package, update it to the fixed version listed below and release the plugin before WordPress 7.2. If you compile CSS modules with @wordpress/build, use version 0.27.0 or later and rebuild. The change in WordPress 7.2 prevents its fixed packages from colliding with older bundled plugin copies, but it does not fix collisions between two old plugin bundles.

What WordPress CSS module collisions affect

In the November 16 dev note, Lena Morita explains that some plugins ship their own copies of WordPress packages rather than loading shared scripts. A bug in @wordpress/build meant CSS module class names depended on the file path and class name, rather than changing when the defining CSS changed.

When differently styled copies were present on the same page, their styles could apply across components. The note gives a focus ring appearing on every hovered tab as one example. It says the issue affects all versions of the named packages published before the fix.

This is a specific compatibility issue for plugin developers who bundle these packages. The note does not describe a general change to how all WordPress themes or plugins handle CSS.

Package versions with the fix

For plugins bundling the packages below, Core advises updating to the listed version or later and releasing a new plugin version before WordPress 7.2.

Bundled packageFirst version with the fix
@wordpress/ui0.26.0
@wordpress/dataviews22.0.0
@wordpress/admin-ui3.1.0
@wordpress/grid0.11.0
@wordpress/components44.0.0

There is an exception for @wordpress/components: if the plugin loads it through the wp-components script, WordPress 7.2 supplies the fixed copy. The separate version check applies when a plugin bundles its own copy.

Update @wordpress/build and rebuild CSS

Plugins that compile their own CSS modules with @wordpress/build should update the tool to 0.27.0 or later, then rebuild. Updating only the package without rebuilding would not complete the action specified in the dev note.

The change in WordPress 7.2 makes generated class names change when their defining CSS changes. Copies share a class name only when their CSS is identical. That prevents an older plugin copy from colliding with a fixed copy shipped in WordPress 7.2.

There is a boundary to that fix: two plugin bundles built before the change can still collide with each other. The note gives separate older versions of @wordpress/ui bundled by two plugins as an example. Updating to WordPress 7.2 alone does not remove that scenario.

What plugin developers should check

Start with the packages your plugin actually bundles. Compare their versions with the table, and check whether your build compiles CSS modules using @wordpress/build. The Core guidance is to update affected packages, publish a plugin release before WordPress 7.2, and rebuild CSS modules with the fixed build tool.

That distinction matters during compatibility work: a site can run the fixed WordPress packages and still have two plugins shipping older, pre-fix copies. Plugin authors who bundle these components should verify their own dependencies instead of assuming the WordPress update covers every copy.

FAQ

What causes the CSS module collision?

The affected build process could give differently styled package copies the same CSS module class names. When both copies loaded on a page, styles from one could affect the other’s components.

Does WordPress 7.2 fix every collision?

No. The change prevents collisions between the fixed packages shipped with WordPress 7.2 and older plugin bundles. Two separate plugin bundles built before the fix can still collide with each other.

What should a plugin developer update?

Update any bundled package listed in the Core note to its stated fixed version or later, then release the plugin before WordPress 7.2. If the plugin builds CSS modules with @wordpress/build, update to 0.27.0 or later and rebuild.

Next step: inspect your plugin’s bundled @wordpress/* dependencies and build process against the versions in the dev note.

Leave a Reply

Your email address will not be published. Required fields are marked *