From a6e2d50b0cc1dda743702e8aa12a0d001f2f2bfb Mon Sep 17 00:00:00 2001 From: Justin Edmund Date: Mon, 26 Dec 2022 05:13:15 -0800 Subject: [PATCH] Add new event handlers to Login/Signup --- components/LoginModal/index.tsx | 15 ++++++++++++++- components/SignupModal/index.tsx | 15 ++++++++++++++- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/components/LoginModal/index.tsx b/components/LoginModal/index.tsx index fac799ec..141cec85 100644 --- a/components/LoginModal/index.tsx +++ b/components/LoginModal/index.tsx @@ -171,6 +171,15 @@ const LoginModal = (props: Props) => { }) } + function onEscapeKeyDown(event: KeyboardEvent) { + setOpen(false) + } + + function onOpenAutoFocus(event: Event) { + event.preventDefault() + if (emailInput.current) emailInput.current.focus() + } + return ( @@ -178,7 +187,11 @@ const LoginModal = (props: Props) => { {t('menu.login')} - +

{t('modals.login.title')}

diff --git a/components/SignupModal/index.tsx b/components/SignupModal/index.tsx index d8909927..0ea8948d 100644 --- a/components/SignupModal/index.tsx +++ b/components/SignupModal/index.tsx @@ -263,6 +263,15 @@ const SignupModal = (props: Props) => { }) } + function onEscapeKeyDown(event: KeyboardEvent) { + setOpen(false) + } + + function onOpenAutoFocus(event: Event) { + event.preventDefault() + if (usernameInput.current) usernameInput.current.focus() + } + return ( @@ -270,7 +279,11 @@ const SignupModal = (props: Props) => { {t('menu.signup')} - +

{t('modals.signup.title')}