Skip to content

Commit ab463f6

Browse files
committed
refactor(styled input): improve handling of name/id props
1 parent 20ad758 commit ab463f6

File tree

1 file changed

+5
-3
lines changed
  • packages/kit-styled/src/components/input

1 file changed

+5
-3
lines changed

packages/kit-styled/src/components/input/input.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,25 @@ export const Input = component$<InputProps>(
1212
'bind:value': valueSig,
1313
// eslint-disable-next-line @typescript-eslint/no-unused-vars
1414
'bind:checked': checkedSig,
15+
id,
1516
...props
1617
}) => {
18+
const inputId = id || name;
1719
return (
1820
<>
1921
<input
2022
{...props}
21-
aria-errormessage={`${name}-error`}
23+
aria-errormessage={`${inputId}-error`}
2224
aria-invalid={!!error}
2325
bind:value={valueSig}
2426
class={cn(
2527
'flex h-12 w-full rounded-base border border-input bg-background px-3 py-1 text-sm text-foreground shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50',
2628
props.class,
2729
)}
28-
id={name}
30+
id={inputId}
2931
/>
3032
{error && (
31-
<div id={`${name}-error`} class="text-destructive mt-1 text-sm">
33+
<div id={`${inputId}-error`} class="text-destructive mt-1 text-sm">
3234
{error}
3335
</div>
3436
)}

0 commit comments

Comments
 (0)