From 1a47548fe3b0b49cb26b15b5bb75448ddece744c Mon Sep 17 00:00:00 2001 From: mwleklinskiVL Date: Tue, 9 Jan 2024 16:33:15 +0100 Subject: [PATCH 1/2] fix: NO-JIRA add id and defaultValue to inputPropsKeys --- src/services/extractInputProps/extractInputProps.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/services/extractInputProps/extractInputProps.ts b/src/services/extractInputProps/extractInputProps.ts index 74e6d99e..f7392519 100644 --- a/src/services/extractInputProps/extractInputProps.ts +++ b/src/services/extractInputProps/extractInputProps.ts @@ -26,7 +26,8 @@ const inputPropsKeys = [ 'src', 'step', 'value', - + 'id', + 'defaultValue', 'onClick', 'onChange', 'onKeyDown', From 71dfb0723d5dabb482e3303b3a2fb5ceded7828c Mon Sep 17 00:00:00 2001 From: mwleklinskiVL Date: Tue, 9 Jan 2024 16:44:07 +0100 Subject: [PATCH 2/2] fix: NO-JIRA add defaultValue prop to TextInput component --- src/components/TextInput/TextInput.tsx | 2 ++ src/components/TextInput/useTextInput.ts | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/components/TextInput/TextInput.tsx b/src/components/TextInput/TextInput.tsx index 0ebfb83f..ace1bb0f 100644 --- a/src/components/TextInput/TextInput.tsx +++ b/src/components/TextInput/TextInput.tsx @@ -22,6 +22,7 @@ export const TextInput = forwardRef< state, hasClearButton, value, + defaultValue, ...restProps }, inputRef, @@ -39,6 +40,7 @@ export const TextInput = forwardRef< } = useTextInput({ beforeComponent, afterComponent, + defaultValue, ...restProps, }); diff --git a/src/components/TextInput/useTextInput.ts b/src/components/TextInput/useTextInput.ts index 0e293778..efea8bc9 100644 --- a/src/components/TextInput/useTextInput.ts +++ b/src/components/TextInput/useTextInput.ts @@ -20,9 +20,10 @@ export const useTextInput = ({ beforeComponent, afterComponent, onChange, + defaultValue, ...restProps }: Omit) => { - const [innerValue, setInnerValue] = useState(''); + const [innerValue, setInnerValue] = useState(defaultValue ?? ''); const styles = useMemo( () => stylesBuilder(custom, beforeComponent?.type, afterComponent?.type), [afterComponent?.type, beforeComponent?.type, custom],