Commit a174161ff5 for woocommerce
commit a174161ff54b2f0c6e6d722f304faf62e84f553e
Author: Sam Seay <samueljseay@gmail.com>
Date: Fri Dec 12 03:15:25 2025 +1300
Define Mini Cart dimension CSS variables solely within the block (#62384)
* Redefine Mini Cart dimension variables with specificity to ensure they're respected.
* Add changefile(s) from automation for the following project(s): woocommerce
* Remove the CSS declaration of the drawer-width and rely on setting it in the block instead.
---------
Co-authored-by: github-actions <github-actions@github.com>
diff --git a/plugins/woocommerce/changelog/62384-wooplug-4976-interactivity-api-powered-mini-cart-dimensions-attribute-not b/plugins/woocommerce/changelog/62384-wooplug-4976-interactivity-api-powered-mini-cart-dimensions-attribute-not
new file mode 100644
index 0000000000..a8a61a0aa3
--- /dev/null
+++ b/plugins/woocommerce/changelog/62384-wooplug-4976-interactivity-api-powered-mini-cart-dimensions-attribute-not
@@ -0,0 +1,4 @@
+Significance: patch
+Type: fix
+
+Fix a bug where the `Dimension` block attribute of Mini-Cart Contents was not respected.
\ No newline at end of file
diff --git a/plugins/woocommerce/client/blocks/assets/js/base/components/drawer/style.scss b/plugins/woocommerce/client/blocks/assets/js/base/components/drawer/style.scss
index cdf0328577..c59398509a 100644
--- a/plugins/woocommerce/client/blocks/assets/js/base/components/drawer/style.scss
+++ b/plugins/woocommerce/client/blocks/assets/js/base/components/drawer/style.scss
@@ -1,9 +1,3 @@
-:root {
- /* This value might be overridden in PHP based on the attribute set by the user. */
- --drawer-width: 480px;
- --neg-drawer-width: calc(var(--drawer-width) * -1);
-}
-
$drawer-animation-duration: 0.3s;
@keyframes fadein {
diff --git a/plugins/woocommerce/src/Blocks/BlockTypes/MiniCartContents.php b/plugins/woocommerce/src/Blocks/BlockTypes/MiniCartContents.php
index 33dac75db9..28d086c7cd 100644
--- a/plugins/woocommerce/src/Blocks/BlockTypes/MiniCartContents.php
+++ b/plugins/woocommerce/src/Blocks/BlockTypes/MiniCartContents.php
@@ -151,10 +151,10 @@ class MiniCartContents extends AbstractBlock {
),
);
- $parsed_style = '';
- if ( array_key_exists( 'width', $attributes ) ) {
- $parsed_style .= ':root{--drawer-width: ' . esc_html( $attributes['width'] ) . '}';
- }
+ $parsed_style = sprintf(
+ ':root { --drawer-width: %s; --neg-drawer-width: calc(var(--drawer-width) * -1); }',
+ esc_html( $attributes['width'] )
+ );
foreach ( $styles as $style ) {
$selector = is_array( $style['selector'] ) ? implode( ',', $style['selector'] ) : $style['selector'];