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)
This commit is contained in:
Raphaël Bosi
2025-06-02 13:42:08 +02:00
committed by GitHub
parent 2001041a48
commit f0d85ea868

View File

@ -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;
};