Skip to content

Commit 8830982

Browse files
committed
fix: improve OAuth button state handling and accessibility
- Move setOauthLoading(null) to finally block in both forms Ensures loading state is always reset, even if OAuth redirects or errors - Add aria-label for screen readers when OAuth buttons show spinner Buttons now have 'Signing in with GitHub/Google' accessible name during loading - Add sr-only span with provider name alongside Loader2 spinner Provides accessible text for assistive technologies
1 parent b47637e commit 8830982

2 files changed

Lines changed: 24 additions & 4 deletions

File tree

frontend/src/components/auth/LoginForm.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ export function LoginForm() {
3939
await signInWithGitHub()
4040
} catch (err: any) {
4141
setError(err.message || 'GitHub sign in failed')
42+
} finally {
4243
setOauthLoading(null)
4344
}
4445
}
@@ -50,6 +51,7 @@ export function LoginForm() {
5051
await signInWithGoogle()
5152
} catch (err: any) {
5253
setError(err.message || 'Google sign in failed')
54+
} finally {
5355
setOauthLoading(null)
5456
}
5557
}
@@ -152,9 +154,13 @@ export function LoginForm() {
152154
className="h-10"
153155
onClick={handleGitHubSignIn}
154156
disabled={loading || oauthLoading !== null}
157+
aria-label={oauthLoading === 'github' ? 'Signing in with GitHub' : undefined}
155158
>
156159
{oauthLoading === 'github' ? (
157-
<Loader2 className="w-4 h-4 animate-spin" />
160+
<>
161+
<Loader2 className="w-4 h-4 animate-spin" />
162+
<span className="sr-only">Signing in with GitHub</span>
163+
</>
158164
) : (
159165
<>
160166
<Github className="w-4 h-4 mr-2" />
@@ -168,9 +174,13 @@ export function LoginForm() {
168174
className="h-10"
169175
onClick={handleGoogleSignIn}
170176
disabled={loading || oauthLoading !== null}
177+
aria-label={oauthLoading === 'google' ? 'Signing in with Google' : undefined}
171178
>
172179
{oauthLoading === 'google' ? (
173-
<Loader2 className="w-4 h-4 animate-spin" />
180+
<>
181+
<Loader2 className="w-4 h-4 animate-spin" />
182+
<span className="sr-only">Signing in with Google</span>
183+
</>
174184
) : (
175185
<>
176186
<svg className="w-4 h-4 mr-2" viewBox="0 0 24 24">

frontend/src/components/auth/SignupForm.tsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ export function SignupForm() {
5050
await signInWithGitHub()
5151
} catch (err: any) {
5252
setError(err.message || 'GitHub sign in failed')
53+
} finally {
5354
setOauthLoading(null)
5455
}
5556
}
@@ -61,6 +62,7 @@ export function SignupForm() {
6162
await signInWithGoogle()
6263
} catch (err: any) {
6364
setError(err.message || 'Google sign in failed')
65+
} finally {
6466
setOauthLoading(null)
6567
}
6668
}
@@ -180,9 +182,13 @@ export function SignupForm() {
180182
className="h-10"
181183
onClick={handleGitHubSignIn}
182184
disabled={loading || oauthLoading !== null}
185+
aria-label={oauthLoading === 'github' ? 'Signing in with GitHub' : undefined}
183186
>
184187
{oauthLoading === 'github' ? (
185-
<Loader2 className="w-4 h-4 animate-spin" />
188+
<>
189+
<Loader2 className="w-4 h-4 animate-spin" />
190+
<span className="sr-only">Signing in with GitHub</span>
191+
</>
186192
) : (
187193
<>
188194
<Github className="w-4 h-4 mr-2" />
@@ -196,9 +202,13 @@ export function SignupForm() {
196202
className="h-10"
197203
onClick={handleGoogleSignIn}
198204
disabled={loading || oauthLoading !== null}
205+
aria-label={oauthLoading === 'google' ? 'Signing in with Google' : undefined}
199206
>
200207
{oauthLoading === 'google' ? (
201-
<Loader2 className="w-4 h-4 animate-spin" />
208+
<>
209+
<Loader2 className="w-4 h-4 animate-spin" />
210+
<span className="sr-only">Signing in with Google</span>
211+
</>
202212
) : (
203213
<>
204214
<svg className="w-4 h-4 mr-2" viewBox="0 0 24 24">

0 commit comments

Comments
 (0)