From 41d641eb43e45f3eb8112588a0e6ccbb11c585c5 Mon Sep 17 00:00:00 2001 From: Vitaly Rtishchev Date: Tue, 4 Oct 2022 17:20:04 +0400 Subject: [PATCH] [@mantine/hooks] use-focus-trap: Fix incorrect focus trapping logic when setRef is called with null (#2623) --- src/mantine-hooks/src/use-focus-trap/use-focus-trap.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/mantine-hooks/src/use-focus-trap/use-focus-trap.ts b/src/mantine-hooks/src/use-focus-trap/use-focus-trap.ts index 3f72b1cc547..fc55a6b63f3 100644 --- a/src/mantine-hooks/src/use-focus-trap/use-focus-trap.ts +++ b/src/mantine-hooks/src/use-focus-trap/use-focus-trap.ts @@ -13,6 +13,10 @@ export function useFocusTrap(active = true): (instance: HTMLElement | null) => v return; } + if (node === ref.current || node === null) { + return; + } + if (restoreAria.current) { restoreAria.current(); }