material-ui icon indicating copy to clipboard operation
material-ui copied to clipboard

[TextField] Does not react to an empty value when used with multiline

Open novembrea opened this issue 9 years ago • 3 comments

I've stumbled upon this behavior after attempting to clear controlled TextField upon submitting its content, i.e. handleSubmit = () => this.setState({value: ""}); but the multilined TextField will not respond to an empty string, anything else will work though. Here's a simple demo: https://codesandbox.io/s/145wok5zw4

Since removing multiline prop will make things work as expected, I assumed it might be something exclusive to the Textarea.js module, but I did not have time to look at it yet. Version v1.0.0-beta.13

novembrea avatar Oct 05 '17 15:10 novembrea

https://github.com/callemall/material-ui/blob/4da17a67182a212be91a36cec9c976ccb6293380/src/Input/Input.js#L564 <textarea value={value ? String(value) : undefined} /> When the value of the textarea is undefined, the previous value does not change.

chilbi avatar Oct 05 '17 16:10 chilbi

The irony is that it's a regression introduced by increasing the type checking (flow) of the lib with https://github.com/callemall/material-ui/commit/6f815c5cda#diff-deaeb5c7e253bfa4f497fa8ace0b3607R538 by @rosskevin

I'm on it. I'm gonna add a unit test to prevent future regression.

oliviertassinari avatar Oct 05 '17 18:10 oliviertassinari

@oliviertassinari - yes I remember that one, I wasn't 100% sure about that in my flow fixing delirium. Thanks for taking care of that.

rosskevin avatar Oct 05 '17 18:10 rosskevin