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

[TextField] Floating label doesn't reset when resetting the form node

Open jgoux opened this issue 9 years ago • 5 comments

Hello,

Problem description

When I reset a form with uncontrolled inputs in it, the values are cleared but the floating label doesn't reset inside the TextField.

Link to minimally-working code that reproduces the issue

http://www.webpackbin.com/4kIJtmmNf

Versions

  • Material-UI: 0.16.5
  • React: 15.4.1
  • Browser: Chrome Version 55.0.2883.87 m (Win10)

jgoux avatar Dec 21 '16 08:12 jgoux

@jgoux, why did you reset() a form with no initial values?

when a form is reset, each control's current value is reset to its initial value. If a control does not have an initial value, the effect of a form reset on that control is undefined. – W3C

ghost avatar Dec 27 '16 21:12 ghost

@frooeyzanny I think @jgoux wants to reset the form after the uncontrolled <TextField /> got input value.

In this case, the <TextField />'s <input> (a form element) got reset by the form reset event but <TextField /> itself, being a React element with existing, persistent state, never got reset to its initial state.

@frooeyzanny Adding a reset function to <TextField>, which will set states to its initial values, will fix this. But onSubmit handler must call it manually using a ref.

quangta93 avatar Jan 06 '17 05:01 quangta93

We have been porting the component on the v1-beta branch. We reimplemented it from the ground-up. While we haven't tested it, I think that the issue is most likely fixed on that branch. Hence, I'm closing it. Still, we will accept PR fixes until v1-beta takes over the master branch.

oliviertassinari avatar Aug 24 '17 20:08 oliviertassinari

@oliviertassinari I don think the issue is still fixed. On submit of data , i'm calling event.target.reset() this is resetting the form but the labels are still floating.

gauravsoni1 avatar Dec 15 '18 10:12 gauravsoni1

@gauravsoni1 It's because React doesn't trigger any callback. The issue should be fixed on the React side. As far as I know.

oliviertassinari avatar Dec 15 '18 10:12 oliviertassinari