Skip to content

Commit e311485

Browse files
committed
fix: add id to NumberFieldInput
1 parent 67710bf commit e311485

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/components/Form/NumberField/NumberFieldInput.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useEffect, useRef, useState } from 'react';
1+
import { useEffect, useId, useRef, useState } from 'react';
22

33
import { parseNumber } from '@douglasneuroinformatics/libjs';
44
import type { NumberFormField } from '@douglasneuroinformatics/libui-form-types';
@@ -27,6 +27,7 @@ export const NumberFieldInput = ({
2727
setValue,
2828
value
2929
}: NumberFieldInputProps) => {
30+
const id = useId();
3031
const [inputValue, setInputValue] = useState(value?.toString() ?? '');
3132
const valueRef = useRef<number | undefined>(value);
3233

@@ -65,11 +66,12 @@ export const NumberFieldInput = ({
6566
return (
6667
<FieldGroup name={name}>
6768
<FieldGroup.Row>
68-
<Label>{label}</Label>
69+
<Label htmlFor={id}>{label}</Label>
6970
<FieldGroup.Description description={description} />
7071
</FieldGroup.Row>
7172
<Input
7273
disabled={disabled || readOnly}
74+
id={id}
7375
max={max}
7476
min={min}
7577
name={name}

0 commit comments

Comments
 (0)