Skip to content
This repository has been archived by the owner on Jun 28, 2021. It is now read-only.

Support for programmatic change of Textfield value #58

Closed
wants to merge 1 commit into from
Closed

Support for programmatic change of Textfield value #58

wants to merge 1 commit into from

Conversation

faergeek
Copy link
Contributor

This will correctly work with floatingLabel when
change from empty value or to empty value

@tleunen
Copy link
Owner

tleunen commented Sep 29, 2015

What's the usecase?
Would have thought that because the value has changed, the textfield is re-rendered and therefore MDL should check the validity.

@faergeek
Copy link
Contributor Author

Try to update value using react-devtools from empty to some value and backwards. If value assigned programmatically, then label will be under real text and vice versa.

@faergeek
Copy link
Contributor Author

I have a real use case where I'm editing images and when I switch them some images have filled values and some don't.

@faergeek
Copy link
Contributor Author

Not sure if it's needed for validation, though.

@tleunen
Copy link
Owner

tleunen commented Sep 29, 2015

Good catch.
Actually, this is because the MDL object is already initialized.
We might want to use .change() on the MDL object if we detect the value has changed.

@faergeek
Copy link
Contributor Author

I tried using .change(), seems like it doesn't work that way. Did you test it?

@tleunen
Copy link
Owner

tleunen commented Sep 29, 2015

Not yet no... But it should work since it updates the css.

@faergeek
Copy link
Contributor Author

Usually such methods assume that you know what you're doing and handled everything, so it does not dispatch event.

@faergeek
Copy link
Contributor Author

Ping

@faergeek
Copy link
Contributor Author

faergeek commented Oct 4, 2015

@tleunen So what about that PR?

@tleunen
Copy link
Owner

tleunen commented Oct 4, 2015

Did not get a chance to test it yet. Should do that tomorrow.

@faergeek
Copy link
Contributor Author

faergeek commented Oct 6, 2015

Just did a rebase on master.
Also I don't see any way to trigger change event at all.

@tleunen
Copy link
Owner

tleunen commented Oct 9, 2015

So I checked it, with react-devtools, and there one thing I don't understand... When changing the value, the textfield component receive an event in componentDidUpdate where the prevProps are the props with the value I entered, and props empty.

But it should be the opposite.

@faergeek
Copy link
Contributor Author

faergeek commented Oct 9, 2015

If you're testing this in demos then you can just see other fields updating too as there are rerender of parent component and we have no shouldComponentUpdate (and we really should) for them.

I checked it, everything is alright, except we should add shouldComponentUpdate hook here and I think in more places across library (will make another PR for that).

@faergeek
Copy link
Contributor Author

faergeek commented Oct 9, 2015

I just did a rebase on top of master.

@faergeek
Copy link
Contributor Author

Can we talk about that problem in a more real time way? May be gitter or something like that?

@tleunen
Copy link
Owner

tleunen commented Oct 14, 2015

I created the gitter room so we can discuss about it :)

This will correctly work with floatingLabel when
change from empty value or to empty value
@tleunen
Copy link
Owner

tleunen commented Oct 16, 2015

closing this in favor of #79

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants