-
Couldn't load subscription status.
- Fork 150
Open
Description
RMWC Version: 14.3.5
Description:
- When I use TextField (textarea)
- And pass there
{...register('message')}fromreact-hook-form - And I also have
characterCountand by default it shows0/20
<TextField
textarea
label="textarea..."
maxLength={20}
characterCount
{...register('message')}
/>
- Then I enter some value and the counter shows
3/20which is correct
- Also I have a button
sendfor sending a message.
- And when I click on the button I need to reset the value and I call
setValue('message', '')for this.
Actual: The value is cleared, but the characterCount is still 3/20.
Expected: The value is cleared, but the characterCount is 0/20.
Full code for reproducing:
import { Controller, useFormContext } from 'react-hook-form';
const Bug = () => {
const { register, setValue } = useFormContext<{
message: string;
}>();
return (
<>
<TextField
textarea
label="textarea..."
maxLength={20}
characterCount
{...register('message')}
/>
<button
onClick={() => {
setValue('message', '');
}}
>
Send
</button>
</>
);
};
Metadata
Metadata
Assignees
Labels
No labels