Fixed onTyping function being called on every type

This commit is contained in:
Martin Berg Alstad 2023-01-10 22:50:29 +01:00
parent c3e6414504
commit 4084522528

View File

@ -39,6 +39,7 @@ function setSetIsText(id: string | undefined, isText: boolean, setIsText: Setter
interface Input<T> extends InputProps<T> { interface Input<T> extends InputProps<T> {
leading?: JSX.Element, leading?: JSX.Element,
trailing?: JSX.Element, trailing?: JSX.Element,
onChange?: () => void,
} }
export const Input: Component<Input<HTMLInputElement>> = ( export const Input: Component<Input<HTMLInputElement>> = (
@ -88,8 +89,12 @@ export const Input: Component<Input<HTMLInputElement>> = (
type={ type } type={ type }
placeholder={ placeholder ?? undefined } placeholder={ placeholder ?? undefined }
required={ required } required={ required }
onInput={ () => setSetIsText(id, isText(), setIsText) } onInput={ () => {
onChange={ onChange /*TODO only called after ENTER*/ }/> setSetIsText(id, isText(), setIsText);
if (onChange) {
onChange();
}
} } />
{ trailing } { trailing }
</Row> </Row>
); );