|
1 | 1 | import {pick} from 'ramda'; |
2 | 2 | import React, { |
| 3 | + InputHTMLAttributes, |
3 | 4 | KeyboardEvent, |
4 | 5 | KeyboardEventHandler, |
5 | 6 | useCallback, |
6 | 7 | useEffect, |
7 | 8 | useRef, |
8 | 9 | useState, |
9 | | - useId, |
10 | 10 | } from 'react'; |
| 11 | +import uniqid from 'uniqid'; |
11 | 12 | import fastIsNumeric from 'fast-isnumeric'; |
12 | 13 | import LoadingElement from '../utils/_LoadingElement'; |
13 | 14 | import './css/input.css'; |
@@ -330,7 +331,7 @@ function Input({ |
330 | 331 | const input = useRef(document.createElement('input')); |
331 | 332 | const [value, setValue] = useState<InputProps['value']>(props.value); |
332 | 333 | const [pendingEvent, setPendingEvent] = useState<number>(); |
333 | | - const inputId = useId(); |
| 334 | + const inputId = useState(() => uniqid('input-'))[0]; |
334 | 335 |
|
335 | 336 | const valprops = |
336 | 337 | props.type === HTMLInputTypes.number ? {} : {value: value ?? ''}; |
@@ -401,7 +402,11 @@ function Input({ |
401 | 402 | value = convert(value); |
402 | 403 |
|
403 | 404 | if (!isEquivalent(base, value)) { |
404 | | - input.current.value = `${value}` ?? ''; |
| 405 | + if (typeof value === 'undefined') { |
| 406 | + input.current.value = ''; |
| 407 | + } else { |
| 408 | + input.current.value = `${value}`; |
| 409 | + } |
405 | 410 | } |
406 | 411 | }, |
407 | 412 | [] |
@@ -490,7 +495,10 @@ function Input({ |
490 | 495 | } |
491 | 496 | }, [value, props.debounce, props.type]); |
492 | 497 |
|
493 | | - const pickedInputs = pick(inputProps, props); |
| 498 | + const pickedInputs = pick( |
| 499 | + inputProps, |
| 500 | + props |
| 501 | + ) as InputHTMLAttributes<HTMLInputElement>; |
494 | 502 |
|
495 | 503 | const isNumberInput = props.type === HTMLInputTypes.number; |
496 | 504 | const currentNumericValue = convert(input.current.value || '0'); |
|
0 commit comments