Skip to content

Commit

Permalink
fix(ui): support keep clicking "Enter" in admin registration (#1846)
Browse files Browse the repository at this point in the history
* fix(ui): support keep clicking enter for admin registration

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
  • Loading branch information
wwayne and autofix-ci[bot] authored Apr 15, 2024
1 parent 75a1b2c commit 733b4a6
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions ee/tabby-ui/app/auth/signup/components/admin-register.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use client'

import { useEffect, useState } from 'react'
import { useEffect, useRef, useState } from 'react'
import { useRouter } from 'next/navigation'

import { cn } from '@/lib/utils'
Expand Down Expand Up @@ -35,6 +35,7 @@ function AdminRegisterStep({
export default function AdminRegister() {
const router = useRouter()
const [currentStep, setCurrentStep] = useState(1)
const goDashboardBtnRef = useRef<HTMLButtonElement>(null)

useEffect(() => {
if (currentStep === 1) return
Expand Down Expand Up @@ -71,7 +72,10 @@ export default function AdminRegister() {
password and cannot recover it for you.
</p>
<UserAuthForm
onSuccess={() => setCurrentStep(3)}
onSuccess={() => {
setCurrentStep(3)
goDashboardBtnRef.current?.focus()
}}
buttonClass="self-start w-48"
/>
</AdminRegisterStep>
Expand All @@ -87,7 +91,11 @@ export default function AdminRegister() {
To start, navigate to the dashboard and invite other members to join
your server.
</p>
<Button className="mt-5 w-48" onClick={() => router.replace('/')}>
<Button
className="mt-5 w-48 focus-visible:ring-0"
onClick={() => router.replace('/')}
ref={goDashboardBtnRef}
>
Go to dashboard
</Button>
</AdminRegisterStep>
Expand Down

0 comments on commit 733b4a6

Please sign in to comment.