Material-ui: [TextField] Does not react to an empty value when used with multiline

Created on 5 Oct 2017  路  3Comments  路  Source: mui-org/material-ui

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

bug 馃悰 TextareaAutosize

Most helpful comment

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

All 3 comments

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.

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 - yes I remember that one, I wasn't 100% sure about that in my flow fixing delirium. Thanks for taking care of that.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ryanflorence picture ryanflorence  路  3Comments

zabojad picture zabojad  路  3Comments

chris-hinds picture chris-hinds  路  3Comments

rbozan picture rbozan  路  3Comments

revskill10 picture revskill10  路  3Comments