Skip to content

Commit

Permalink
fix(textinput): reset character count on clear
Browse files Browse the repository at this point in the history
The empty value passed from the parent on clear was not being applied as that value was only an
initial value in TextInput's useState

fix #295
  • Loading branch information
blakekrammes committed Sep 3, 2021
1 parent f8d17bf commit abd36a5
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/components/TextInput/TextInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,10 @@ const TextInput = ({
const handleClear = (e: any) =>
handleEventWithAnalytics('TextInput', onClear, 'onClear', e, containerProps);

if (internalValue !== nativeHTMLAttributes.value && nativeHTMLAttributes.value === '') {
setInternalValue('');
}

return (
<StyledContainer
disabled={nativeHTMLAttributes.disabled}
Expand Down

0 comments on commit abd36a5

Please sign in to comment.