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:
@@ -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>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user