Skip to content

Commit 1cac820

Browse files
committed
fix(web): announce provider icon URL validation errors
1 parent 070c3c8 commit 1cac820

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

‎apps/web/src/components/settings/ProviderIconUrlInput.tsx‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useState } from "react";
1+
import { useId, useState } from "react";
22
import { normalizeProviderIconUrl, type ProviderDriverKind } from "@t3tools/contracts";
33
import { Input } from "../ui/input";
44
import { Button } from "../ui/button";
@@ -11,6 +11,7 @@ export function ProviderIconUrlInput(props: {
1111
readonly disabled?: boolean;
1212
readonly onCommit: (value: string) => void;
1313
}) {
14+
const errorId = useId();
1415
const [draft, setDraft] = useState<{ saved: string | undefined; value: string } | null>(null);
1516
const value = draft !== null && draft.saved === props.value ? draft.value : (props.value ?? "");
1617
const invalid = value.trim() !== "" && normalizeProviderIconUrl(value) === null;
@@ -29,6 +30,7 @@ export function ProviderIconUrlInput(props: {
2930
<Input
3031
aria-label="Instance icon URL"
3132
aria-invalid={invalid || undefined}
33+
aria-describedby={invalid ? errorId : undefined}
3234
size="sm"
3335
type="url"
3436
value={value}
@@ -57,7 +59,9 @@ export function ProviderIconUrlInput(props: {
5759
</Button>
5860
</div>
5961
{invalid ? (
60-
<p className="text-xs text-destructive">Enter an HTTPS image URL without credentials.</p>
62+
<p id={errorId} role="alert" className="text-xs text-destructive">
63+
Enter an HTTPS image URL without credentials.
64+
</p>
6165
) : null}
6266
</div>
6367
);

0 commit comments

Comments
 (0)