Commit 86a72f39f7 for woocommerce
commit 86a72f39f74fc25df45aa8328cd8d18b7d767cf3
Author: Mario Santos <34552881+SantosGuillamot@users.noreply.github.com>
Date: Wed Dec 17 12:32:32 2025 +0100
Minicart: Fix wrong focus when multiple minicarts are in the page (#62494)
* Save minicart button on click
* Add changefile(s) from automation for the following project(s): woocommerce
* Remove callback from types
---------
Co-authored-by: github-actions <github-actions@github.com>
diff --git a/plugins/woocommerce/changelog/62494-wooplug-6029-minicart-incorrect-focus-when-having-multiple-minicarts b/plugins/woocommerce/changelog/62494-wooplug-6029-minicart-incorrect-focus-when-having-multiple-minicarts
new file mode 100644
index 0000000000..bc6ca423b8
--- /dev/null
+++ b/plugins/woocommerce/changelog/62494-wooplug-6029-minicart-incorrect-focus-when-having-multiple-minicarts
@@ -0,0 +1,4 @@
+Significance: patch
+Type: fix
+
+Fix minicart focus when multiple minicarts are in the page
\ No newline at end of file
diff --git a/plugins/woocommerce/client/blocks/assets/js/blocks/mini-cart/iapi-frontend.ts b/plugins/woocommerce/client/blocks/assets/js/blocks/mini-cart/iapi-frontend.ts
index f50befffd4..98796e44c6 100644
--- a/plugins/woocommerce/client/blocks/assets/js/blocks/mini-cart/iapi-frontend.ts
+++ b/plugins/woocommerce/client/blocks/assets/js/blocks/mini-cart/iapi-frontend.ts
@@ -98,7 +98,6 @@ type MiniCart = {
setupEventListeners: () => void;
disableScrollingOnBody: () => void;
focusFirstElement: () => void;
- saveMiniCartButtonRef: () => void;
};
};
@@ -255,6 +254,8 @@ store< MiniCart >(
window.location.href = checkoutUrl;
return;
}
+ const { ref } = getElement();
+ state.miniCartButtonRef = ref;
state.isOpen = true;
},
@@ -383,11 +384,6 @@ store< MiniCart >(
getFocusableElements( ref )[ 0 ]?.focus();
}
},
-
- saveMiniCartButtonRef() {
- const { ref } = getElement();
- state.miniCartButtonRef = ref;
- },
},
},
{ lock: universalLock }
diff --git a/plugins/woocommerce/src/Blocks/BlockTypes/MiniCart.php b/plugins/woocommerce/src/Blocks/BlockTypes/MiniCart.php
index bfc98ba695..786235e2b9 100644
--- a/plugins/woocommerce/src/Blocks/BlockTypes/MiniCart.php
+++ b/plugins/woocommerce/src/Blocks/BlockTypes/MiniCart.php
@@ -610,7 +610,6 @@ class MiniCart extends AbstractBlock {
style="<?php echo esc_attr( $wrapper_styles ); ?>"
>
<button
- data-wp-init="callbacks.saveMiniCartButtonRef"
data-wp-on--click="actions.openDrawer"
data-wp-bind--aria-label="state.buttonAriaLabel"
class="wc-block-mini-cart__button"