feat(a11y): enhance accessibility of password gate form (#46)

Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
This commit is contained in:
Ralksta
2026-03-27 10:36:22 +01:00
committed by GitHub
parent 5ebc900851
commit c8f75e4615

View File

@@ -51,6 +51,7 @@ export default function PasswordGate({ slug, title }: PasswordGateProps) {
<form onSubmit={handleSubmit} className={styles.form}> <form onSubmit={handleSubmit} className={styles.form}>
<input <input
id="password-input"
type="password" type="password"
value={password} value={password}
onChange={(e) => setPassword(e.target.value)} onChange={(e) => setPassword(e.target.value)}
@@ -59,13 +60,20 @@ export default function PasswordGate({ slug, title }: PasswordGateProps) {
className={styles.input} className={styles.input}
autoFocus autoFocus
required required
disabled={loading}
aria-invalid={!!error}
aria-describedby={error ? 'password-error' : undefined}
/> />
<button type="submit" className={styles.button} disabled={loading}> <button type="submit" className={styles.button} disabled={loading}>
{loading ? 'Verifying…' : 'Enter'} {loading ? 'Verifying…' : 'Enter'}
</button> </button>
</form> </form>
{error && <p className={styles.error}>{error}</p>} {error && (
<p id="password-error" className={styles.error} role="alert" aria-live="polite">
{error}
</p>
)}
</div> </div>
</div> </div>
); );