-
-
Notifications
You must be signed in to change notification settings - Fork 333
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
paper-input: Fix md-input-has-value when value attr is not observable #412
paper-input: Fix md-input-has-value when value attr is not observable #412
Conversation
4b6464b
to
c8094bd
Compare
Where do we assume that?
What do you mean? We're just using a computed property which depends on |
@miguelcobain look at the last test I wrote for this PR. That test fails without the proposed change. |
@miguelcobain in that test the provided "value" is a static empty string (not observable). Also onChange does nothing. So while the value of the input changes, nothing else happens. But for purposes of applying the right classes such as md-input-has-value we need to track the actual change of the input without caring necessarily if the user could or did update the value in the onchange action. |
@dustinfarris paper-input should reflect whatever value it gets from outside. That's the DDAU philosophy. |
@miguelcobain DDAU is still honored by making this a oneway, but we also have to honor MD style rules with the input element itself when its internal value deviates as could easily happen. Otherwise we have bugs like #411 |
Let's imagine the following scenario:
In this case I don't think this PR honors DDAU entirely because: the component should always reflect the state it is given (data down). |
Ok, I am unsure how computed oneway will react to an update like that after it deviated. I'll write a test for this when I'm back at my desk and adjust the implementation if necessary. |
Strange things happen when you don't update the input's Example: https://ember-twiddle.com/a0f4c6ce8ab25734634aadc74e76509d In that twiddle the user wanted to always have |
Ok agreed that this may not be the right approach. The end goal here is to make sure that we apply the md class if the input element has a value. I will rethink implementation to achieve that. |
Thank you for your time. |
@miguelcobain I've added an observer to ensure that future changes to I believe this is good to merge now. |
ffa5f20
to
599d1f6
Compare
This one-way property allows us to keep a current copy of the input's value for internal use when the `value` attr is not updated by the user in the usual way. Changed hasValue to inputHasValue referencing inputValue instead of value.
599d1f6
to
5f036e1
Compare
Given the API for paper-input, we cannot assume that the user is going to update the original value object in their provided onchange closure. We also cannot assume that the provided
value
is observable.This adds a new property to track the actual value of the input for things like binding the
md-input-has-value
class.Fixes #411