Skip to content

Commit 58e7563

Browse files
add support for default input component to call onChange handler with value instead of event (#53)
1 parent 2a1466b commit 58e7563

3 files changed

Lines changed: 22 additions & 14 deletions

File tree

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,5 +138,5 @@
138138
},
139139
"sideEffects": false,
140140
"typings": "types/index.d.ts",
141-
"version": "2.4.2-os24"
141+
"version": "2.4.2-os25"
142142
}

src/components/Input.js

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,18 +40,26 @@ const Input = ({
4040
isHidden,
4141
isDisabled,
4242
theme,
43+
onChange,
4344
selectProps,
4445
...props
45-
}: InputProps) => (
46-
<div style={getStyles('input', { theme, ...props })}>
47-
<AutosizeInput
48-
className={cx(null, { 'input': true }, className)}
49-
inputRef={innerRef}
50-
inputStyle={inputStyle(isHidden)}
51-
disabled={isDisabled}
52-
{...props}
53-
/>
54-
</div>
55-
);
46+
}: InputProps) => {
47+
const onInputChange = (event) => {
48+
onChange(event.currentTarget.value);
49+
}
50+
51+
return (
52+
<div style={getStyles('input', { theme, ...props })}>
53+
<AutosizeInput
54+
{...props}
55+
className={cx(null, { 'input': true }, className)}
56+
inputRef={innerRef}
57+
inputStyle={inputStyle(isHidden)}
58+
disabled={isDisabled}
59+
onChange={onInputChange}
60+
/>
61+
</div>
62+
);
63+
};
5664

5765
export default Input;

0 commit comments

Comments
 (0)