From 17422b7690f52274dc62820e08681638e91514d9 Mon Sep 17 00:00:00 2001
From: Marie <51697796+ijreilly@users.noreply.github.com>
Date: Wed, 17 Apr 2024 10:45:02 +0200
Subject: [PATCH] fix: I should be able to use "enter" key to create profile
(#4978)
## Context
Fixes #4808
TL;DR
Introducing pure stateless modal component ("UI modal") for our auth
modal not to have default hotkeyScope overriding our create-profile
hotkeyScope
+ we dont want the shortcut to be available for all the modal content, only for the input that should not be using a hotkeyscope, so we are using onKeyDown for the specific issue on create profile.
Explanation
create-profile hotkey scope is set by PageChangeEffect; CreateProfile
component adds enter key shortcut; but this scope is overwritten by the
default scope by the Modal component that expects a hotkeyScope to reset
to (and defaults to the default hotkeyScope if none indicated).
In the auth flow we were using that Modal component to give a modal look
to the flow but it is not a modal per say, it's a set of pages contained
within a modal look.
By creating this UI component we are escaping that hotkeyScope
overriding that does not make sense in our context.
## How was it tested
Locally
Storybook
---
.../src/modules/auth/components/Modal.tsx | 8 +-
.../sign-in-up/components/SignInUpForm.tsx | 4 +-
.../auth/sign-in-up/hooks/useSignInUp.tsx | 27 ---
.../ui/layout/modal/components/Modal.tsx | 182 +++---------------
.../layout/modal/components/ModalLayout.tsx | 168 ++++++++++++++++
.../__stories__/ModalLayout.stories.tsx | 36 ++++
.../src/pages/auth/CreateProfile.tsx | 21 +-
7 files changed, 244 insertions(+), 202 deletions(-)
create mode 100644 packages/twenty-front/src/modules/ui/layout/modal/components/ModalLayout.tsx
create mode 100644 packages/twenty-front/src/modules/ui/layout/modal/components/__stories__/ModalLayout.stories.tsx
diff --git a/packages/twenty-front/src/modules/auth/components/Modal.tsx b/packages/twenty-front/src/modules/auth/components/Modal.tsx
index 3a9429270..f40de47cf 100644
--- a/packages/twenty-front/src/modules/auth/components/Modal.tsx
+++ b/packages/twenty-front/src/modules/auth/components/Modal.tsx
@@ -1,9 +1,9 @@
import React from 'react';
import styled from '@emotion/styled';
-import { Modal as UIModal } from '@/ui/layout/modal/components/Modal';
+import { ModalLayout } from '@/ui/layout/modal/components/ModalLayout';
-const StyledContent = styled(UIModal.Content)`
+const StyledContent = styled(ModalLayout.Content)`
align-items: center;
width: calc(400px - ${({ theme }) => theme.spacing(10 * 2)});
`;
@@ -11,7 +11,7 @@ const StyledContent = styled(UIModal.Content)`
type AuthModalProps = { children: React.ReactNode };
export const AuthModal = ({ children }: AuthModalProps) => (
-