From f0d85ea868e4a530ca0d7d2f229cc8e62909409c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Bosi?= <71827178+bosiraphael@users.noreply.github.com> Date: Mon, 2 Jun 2025 13:42:08 +0200 Subject: [PATCH] Fix auth modal closing hotkey scopes (#12407) The auth modal is a particular modal because it is the only one that is opened in an effect (because its opening depends on the location). After the hotkey scopes and the modal refactoring, we are now force to call `openModal` and `closeModal` to open and close the modals. Here, the `closeModal` wasn't called, but the modal was simply unmounted. The global hotkeys were then disabled because the modal was still in the focus stack. Fixes [#1052](https://github.com/twentyhq/core-team-issues/issues/1052#event-17916955590) --- .../src/modules/auth/components/AuthModalMountEffect.tsx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/twenty-front/src/modules/auth/components/AuthModalMountEffect.tsx b/packages/twenty-front/src/modules/auth/components/AuthModalMountEffect.tsx index 37f1483b2..0908433c7 100644 --- a/packages/twenty-front/src/modules/auth/components/AuthModalMountEffect.tsx +++ b/packages/twenty-front/src/modules/auth/components/AuthModalMountEffect.tsx @@ -3,12 +3,17 @@ import { useEffect } from 'react'; import { AUTH_MODAL_ID } from '../constants/AuthModalId'; +// TODO: Remove this component when we refactor the auth modal to open it directly in the PageChangeEffect export const AuthModalMountEffect = () => { - const { openModal } = useModal(); + const { openModal, closeModal } = useModal(); useEffect(() => { openModal(AUTH_MODAL_ID); - }, [openModal]); + + return () => { + closeModal(AUTH_MODAL_ID); + }; + }, [openModal, closeModal]); return null; };