Closed fl4p closed 8 years ago
We had a discussion a bunch of time ago (reflected on how the gold-* elements behave), and the conclusion was that we should validate on blur/change, but not in ready
. It's weird that when you load a form, for example, all of your fields (that say, are just required
) are actually automatically invalid.
So i think paper-input
is actually working correctly, and paper-textarea
is the culprit :)
If you would like to send a PR to fix paper-textarea, that would be awesome!
Oh I think the fix for paper-textarea might be in https://github.com/PolymerElements/paper-input/pull/315!
(which I've noticed is your PR).
I think this can be closed, since the paper-textarea
PR has been already merged.
JSBIN (note that I used the paper-input layer to make it visibility, I think the actual issues lies in iron-input): http://jsbin.com/vetiwupele/1/edit?html,output
Expected outcome
No validation errors.
Actual outcome
Valdation Errors for textareas.
Explanation
I think setting the
this.bindValue = this.value;
should be done in airon-input.attach
, not iniron-input.ready
. At first there might be no difference, but let me explain what I think about this single line: As I understand the intention of this update ofbindValue
, it shall trigger a change event. Looking atpaper-input-container
, it indeed triggers_handleValueAndAutoValidate
, and this conditionally auto-validates the input. However at this point the value ofautoValidate
is always false, because bindings are not yet setup properly. This might never be an actual issue, but it can cause unexpected behaviour when creating own inputs. There is a significant difference in how iron-autogrow-textarea and iron-input get auto validated. Here is an example, on the paper-input layer though, to make it visible http://jsbin.com/vetiwupele/1/edit?html,output . As you can see, the textarea is invalidated, thepaper-inputs
not.Note that there is another issue with
paper-autogrow-textarea
validation https://github.com/PolymerElements/paper-input/pull/315 . But even this pull request would not fix what I showed in the jsbin.Just replacing the
ready
withattach
will break validation of thepaper-input
, though. It has very big impact.An alternative to make validation behavior of
paper-autogrow-textarea
similar topaper-input
is to setthis.bindValue = this.value;
onready
, too. I consider this as a dirty fix, because it also relies on a this not-binded-yet bug inpaper-input-container
's_handleValueAndAutoValidate
. The impact of this would be smaller.Let me know if you think that this whole issue is somewhat important, I can investigate this further.