Add new event handlers to Login/Signup
This commit is contained in:
parent
0c76866b56
commit
a6e2d50b0c
2 changed files with 28 additions and 2 deletions
|
|
@ -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 (
|
return (
|
||||||
<Dialog open={open} onOpenChange={openChange}>
|
<Dialog open={open} onOpenChange={openChange}>
|
||||||
<DialogTrigger asChild>
|
<DialogTrigger asChild>
|
||||||
|
|
@ -178,7 +187,11 @@ const LoginModal = (props: Props) => {
|
||||||
<span>{t('menu.login')}</span>
|
<span>{t('menu.login')}</span>
|
||||||
</li>
|
</li>
|
||||||
</DialogTrigger>
|
</DialogTrigger>
|
||||||
<DialogContent className="Login Dialog">
|
<DialogContent
|
||||||
|
className="Login Dialog"
|
||||||
|
onEscapeKeyDown={onEscapeKeyDown}
|
||||||
|
onOpenAutoFocus={onOpenAutoFocus}
|
||||||
|
>
|
||||||
<div className="DialogHeader">
|
<div className="DialogHeader">
|
||||||
<div className="DialogTitle">
|
<div className="DialogTitle">
|
||||||
<h1>{t('modals.login.title')}</h1>
|
<h1>{t('modals.login.title')}</h1>
|
||||||
|
|
|
||||||
|
|
@ -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 (
|
return (
|
||||||
<Dialog open={open} onOpenChange={openChange}>
|
<Dialog open={open} onOpenChange={openChange}>
|
||||||
<DialogTrigger asChild>
|
<DialogTrigger asChild>
|
||||||
|
|
@ -270,7 +279,11 @@ const SignupModal = (props: Props) => {
|
||||||
<span>{t('menu.signup')}</span>
|
<span>{t('menu.signup')}</span>
|
||||||
</li>
|
</li>
|
||||||
</DialogTrigger>
|
</DialogTrigger>
|
||||||
<DialogContent className="Signup Dialog">
|
<DialogContent
|
||||||
|
className="Signup Dialog"
|
||||||
|
onEscapeKeyDown={onEscapeKeyDown}
|
||||||
|
onOpenAutoFocus={onOpenAutoFocus}
|
||||||
|
>
|
||||||
<div className="DialogHeader">
|
<div className="DialogHeader">
|
||||||
<div className="DialogTitle">
|
<div className="DialogTitle">
|
||||||
<h1>{t('modals.signup.title')}</h1>
|
<h1>{t('modals.signup.title')}</h1>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue