-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Character counter on Textfield component does not update with initial value #2042
Comments
Hey, thanks for the bug report! 🐛 |
I am not using defaultValue because i want the component to be controlled. When page is reloaded this occurs. |
I understand, would something like this work for you? const DEFAULT_VALUE = "default";
export default function Controlled() {
const [value, setValue] = useState(DEFAULT_VALUE);
return (
<Textfield
value={value}
onChange={(e) => setValue(e.target.value)}
defaultValue={DEFAULT_VALUE}
characterLimit={{
maxCount: 9,
}}
/>
);
} edit: I see that this throws a console error 🤔 |
This wont fix my problem because if you reload the page the state is beeing preserved but not the defaultValue. Also if i set the defaultValue initially to my value, then it throws the error you are referring to. I have added a pull-request with a possible solution. #2056 |
Description of the bug
When I write a character in the Textfield component the character counter shows the number of positions left correctly. But after I have saved the value and refreshed the page, The text shows up in the input but the character counter shows the incorrect message "Du har 9 av 9 tegn igjen" (the field is already full). If I start editing in the opened field again, it updates after the first character change and behaves as expected.
Steps To Reproduce
Additional Information
The text was updated successfully, but these errors were encountered: