From d2ac6ff953656b76f6cfc929596b26d2fd15889c Mon Sep 17 00:00:00 2001 From: Seghir Nadir Date: Wed, 22 May 2024 17:03:22 +0200 Subject: [PATCH] Correctly attribute focus back when opening the mini cart several times (#47683) * allow focusedOnMount element to be reset * Add changefile(s) from automation for the following project(s): woocommerce-blocks --------- Co-authored-by: github-actions --- .../assets/js/base/utils/use-return-focus.ts | 5 ----- .../woocommerce/changelog/47683-fix-focus-on-mini-cart-stuck | 4 ++++ 2 files changed, 4 insertions(+), 5 deletions(-) create mode 100644 plugins/woocommerce/changelog/47683-fix-focus-on-mini-cart-stuck diff --git a/plugins/woocommerce-blocks/assets/js/base/utils/use-return-focus.ts b/plugins/woocommerce-blocks/assets/js/base/utils/use-return-focus.ts index 6a8fcad8cfc..9c0f6ea8674 100644 --- a/plugins/woocommerce-blocks/assets/js/base/utils/use-return-focus.ts +++ b/plugins/woocommerce-blocks/assets/js/base/utils/use-return-focus.ts @@ -26,11 +26,6 @@ export function useFocusReturn( // Set ref to be used when unmounting. ref.current = node; - // Only set when the node mounts. - if ( focusedBeforeMount.current ) { - return; - } - focusedBeforeMount.current = node.ownerDocument.activeElement; } else if ( focusedBeforeMount.current ) { const isFocused = ref.current?.contains( diff --git a/plugins/woocommerce/changelog/47683-fix-focus-on-mini-cart-stuck b/plugins/woocommerce/changelog/47683-fix-focus-on-mini-cart-stuck new file mode 100644 index 00000000000..e2d6d2c18e1 --- /dev/null +++ b/plugins/woocommerce/changelog/47683-fix-focus-on-mini-cart-stuck @@ -0,0 +1,4 @@ +Significance: patch +Type: fix +Comment: This PR is a follow up to https://github.com/woocommerce/woocommerce/pull/47470 +