From 1e9467fc0c578a4ae59cfb9d8208a106e4c5568c Mon Sep 17 00:00:00 2001 From: George Mamadashvili Date: Fri, 18 Jun 2021 17:32:14 +0400 Subject: [PATCH] useNavigateRegions: Don't remove click event if there's no element --- packages/components/src/higher-order/navigate-regions/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/components/src/higher-order/navigate-regions/index.js b/packages/components/src/higher-order/navigate-regions/index.js index 93ec95af801e0..db9fc877e9467 100644 --- a/packages/components/src/higher-order/navigate-regions/index.js +++ b/packages/components/src/higher-order/navigate-regions/index.js @@ -53,7 +53,7 @@ export function useNavigateRegions( ref, shortcuts = defaultShortcuts ) { ref.current.addEventListener( 'click', onClick ); return () => { - ref.current.removeEventListener( 'click', onClick ); + ref.current?.removeEventListener( 'click', onClick ); }; }, [ setIsFocusingRegions ] );