-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
fix(textfield): Update label position on value changed via JS #1197
fix(textfield): Update label position on value changed via JS #1197
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1197 +/- ##
==========================================
+ Coverage 99.82% 99.82% +<.01%
==========================================
Files 69 69
Lines 3388 3433 +45
Branches 424 431 +7
==========================================
+ Hits 3382 3427 +45
Misses 6 6
Continue to review full report at Codecov.
|
Sorry @anton-kachurin, we did a lot of text field updates in a big change, and it has caused merge conflicts in this PR. Can you resolve them? Or it might be better to just create a whole new PR. |
@anton-kachurin What's up with this? Would love to see it implemented in MDC |
@touficbatache I've been waiting for a review for longer than a month and the activity log clearly shows that this PR isn't abandoned. At this very moment I'm working on resolving merge conflicts. I don't consider your comment appropriate. This is an open source project, and if you personally would love to see something in it, go ahead and implement it. You always have an option to fork from my fork and take the branch to the point where it can be merged to master. Don't press on volunteers, we're doing it in a spare time. As a part of the community, please be respectful to others. |
I'm sorry, but I'm not being disrespectful. I'm just telling that your work is great by saying that I'd love seeing it implemented, I didn't say that to put pressure on anybody. Have a great day. |
ca6d9eb
to
5db7c8e
Compare
AFAIK this pull request only updates the label-float style after a programmatic change of the input value. However, a change of the input value may affect other styles when the new value introduces or fixes a previous input value error. Hence value changes may also affect the error styles, helptext, and errortext. |
packages/mdc-textfield/foundation.js
Outdated
if (!this.useCustomValidityChecking_) { | ||
this.adapter_.removeClassFromLabel(LABEL_SHAKE); | ||
this.showHelptext_(); | ||
this.changeValidity_(input.checkValidity()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gjdev Validation is handled in this PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I missed that somehow.
Hey @anton-kachurin, I wrote a proposal for a different way to solve #822 (in the #822 thread). Can you check it out and comment on that thread. I'd like to hash out some code architecture details before I can review any code changes to solve #822. |
b40a84e
to
4bbe551
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some initial questions. I'll try and review the rest of it soon.
packages/mdc-textfield/foundation.js
Outdated
|
||
if (this.isFocused_ || input.value) { | ||
if (!this.labelFloatIsActive_) { | ||
this.labelFloatIsActive_ = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of you using this.labelFloatIsActive as a internal state variable to keep track of "if the LABEL_FLOAT_ABOVE class has been added". Why not add a method to the adapter to check adapter_.labelHasClass(LABEL_FLOAT_ABOVE)
?
packages/mdc-textfield/foundation.js
Outdated
this.adapter_.addClassToLabel(LABEL_FLOAT_ABOVE); | ||
} | ||
} else { | ||
if (this.labelFloatIsActive_) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you actually don't even need this check. It doesnt matter what the internal state of this.labelFloatIsActive is....if neither this.isFocused_
or input.value
is true, then you should remove LABEL_FLOAT_ABOVE from the label element.
packages/mdc-textfield/foundation.js
Outdated
this.isFocused_ = false; | ||
this.adapter_.removeClass(FOCUSED); | ||
this.adapter_.removeClassFromLabel(LABEL_SHAKE); | ||
|
||
if (!input.value && !this.isBadInput_()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this.isBadInput be checked within the logic of updateLabelFloat?
@lynnjepsen Regarding your questions above:
Before, the Now we extend the foundation with the
The flag The one main reason why I think it's better to double check before calling
My argument was that the With this in mind, we have to add
The pen above shows that setting the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey Anton, This looks pretty good in general, but I want you to remove the installPropertyChangeHooks from this PR. You can create another PR after this with the installPropertyChangeHooks, but doing both in both PR is a little too hard to review.
Also were (still) doing a fair amount of changes in mdc-textfield directory, so I'm trying to reduce merge conflicts while still getting some of your changes in.
packages/mdc-textfield/foundation.js
Outdated
this.labelFloatIsActive_ = true; | ||
this.adapter_.addClassToLabel(LABEL_FLOAT_ABOVE); | ||
} | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
combine this else, and the if statement on the next line.
packages/mdc-textfield/foundation.js
Outdated
@@ -110,6 +112,7 @@ class MDCTextfieldFoundation extends MDCFoundation { | |||
this.adapter_.registerTextFieldInteractionHandler(evtType, this.textFieldInteractionHandler_); | |||
}); | |||
this.adapter_.registerTransitionEndHandler(this.transitionEndHandler_); | |||
this.installPropertyChangeHooks_(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add these installPropertyChangeHooks
in the next PR. Its a little too hard to review otherwise. And I think that means you don't need the this.setValueIsProcessing_
field.
packages/mdc-textfield/foundation.js
Outdated
this.adapter_.addClass(INVALID); | ||
|
||
if (this.isFocused_) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there a test for this case? A test for when the text fields value is changed programmatically, but the user is not focused on that text field. You should verify that this.adapter_.addClassToLabel(LABEL_SHAKE)
is not called.
698b62a
to
4ca4db6
Compare
a9f0e76
to
6863506
Compare
Returns whether or not the label element contains the given class.
Unfortunately, multiple merge conflict do not allow me to keep working on this PR. Besides, the main reason for me to work on it was to implement a specific feature. Instead, I was asked to refactor the code and not to include the feature, and now all this work is gone. |
The work is continued in #1615 |
Is this issue also related to the new labels of the mdc-select (MDC 0.27.0)? When I set the selectedIndex over there on init, the label is written over the selected value. |
Fixes #822