Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

refactor(text-field): Change text-field--box to be the new default #2859

Merged
merged 47 commits into from
Aug 23, 2018

Conversation

EstebanG23
Copy link
Contributor

@EstebanG23 EstebanG23 commented Jun 1, 2018

Add changes to CSS classes to override necessary styles. Edit README to reflect the new default. Edit JS to match the changes. Change tests and constants to reflect the new changes.

Fixes #2780

Add changes to CSS classes to override necessary styles. Edit README to reflect the new default. Edit JS to match the changes. Edit constants in JS.
@@ -129,17 +129,21 @@
// Baseline

@mixin mdc-text-field-disabled_ {
@include mdc-text-field-bottom-line-color_($mdc-text-field-disabled-border);
@include mdc-text-field-bottom-line-color_($mdc-text-field-outlined-disabled-border);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should use $mdc-text-field-disabled-border here and it should be set to 12% black (I think at least, by eyeballing the spec).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!


@mixin mdc-floating-label-width($width) {
.mdc-floating-label {
width: calc(100% - #{$width});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update this mixin to just set width: $width

Then the calc(...) logic can go in the text field CSS, since the text field handles the icon and that's the reason for subtracting part of the width.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

@include mdc-text-field-ink-color_($mdc-text-field-disabled-ink-color);
@include mdc-text-field-label-ink-color_($mdc-text-field-disabled-label-color);
@include mdc-text-field-helper-text-color_($mdc-text-field-disabled-helper-text-color);
@include mdc-text-field-icon-color_($mdc-text-field-disabled-icon);
@include mdc-text-field-fullwidth-bottom-line-color_($mdc-text-field-fullwidth-bottom-line-color);
@include mdc-text-field-fill-color_($mdc-text-field-disabled-background);
@include mdc-text-field-label-color($mdc-text-field-disabled-label-color);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line 139 can be removed, since the label color is set in line 134.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

pointer-events: none;

.mdc-text-field__input {
border-bottom: 1px dotted;
border-bottom-width: 1px;
border-bottom-style: dotted;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can actually remove the dotted border-bottom-style too because it's no longer in the spec for disabled text fields.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!


height: 56px;
display: inline-flex;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be removed because it's already set in the default text field.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it!

assert.isNull(component.ripple);
});

test('#constructor sets the ripple property to `null` when given a `mdc-text-field--textarea`', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: rename this test #constructor does not instantiate a ripple when ${cssClasses.TEXTAREA} class is present

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

@@ -79,6 +79,7 @@ Mixin | Description
`mdc-floating-label-shake-keyframes($modifier, $positionY, $positionX, $scale)` | Generates a CSS `@keyframes` at-rule for an invalid label shake. Used in conjunction with the `mdc-floating-label-shake-animation` mixin.
`mdc-floating-label-shake-animation($modifier)` | Applies shake keyframe animation to label.
`mdc-floating-label-float-position($positionY, $positionX, $scale)` | Sets position of label when floating.
`mdc-floating-label-width($width))` | Sets width of label when floating.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update the description to be "Sets the width of the label" since it actually sets the width of the label in both its floating and non-floating position.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

>
> Other input types (such as `date`) are not currently supported.
> Other input types (such as `number` and `date`) are not currently supported.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually think this is also from the bad sync. I am reverting it back to how it was.

`mdc-text-field-box-corner-radius($radius)` | Customizes the border radius for the text field box variant.
`mdc-text-field-box-fill-color($color)` | Customizes the background color of the text field box.
`mdc-text-field-corner-radius($radius)` | Customizes the border radius for the text field.
`mdc-text-field-fill-color($color)` | Customizes the background color of the text field.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consolidate the "Other Mixins" table into the "Mixins for Text Field" table. They don't need to be separate anymore since there's no more Box variant.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Complete!

@@ -313,8 +305,6 @@ Method Signature | Description
`activateFocus() => void` | Activates the focus state of the Text Field. Normally called in response to the input focus event.
`deactivateFocus() => void` | Deactivates the focus state of the Text Field. Normally called in response to the input blur event.
`setHelperTextContent(content: string) => void` | Sets the content of the helper text.
`setIconAriaLabel(label: string) => void` | Sets the aria label of the icon.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed accidentally?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I never removed this so it must have been a bad sync on my part. I added it back!

Copy link
Contributor

@kfranqueiro kfranqueiro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I scanned through some of this and left a few comments.

);
});
});
// demoReady(function() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OOC, I'm not sure why this was commented out (I assume it's for the demo for the old default text field variant being removed), but it should be removed entirely if it's supposed to be removed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for catching that!

@@ -144,19 +152,6 @@
@include mdc-text-field-dense-with-trailing-icon_;
}

.mdc-text-field--upgraded:not(.mdc-text-field--fullwidth):not(.mdc-text-field--box) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm confused as to why this was entirely removed? AFAICT the --upgraded modifier is no longer used if we remove this.

Historically we supported text field both CSS-only and with JS, which is why this modifier existed. Support for that was dropped more recently due to all of the work going into the filled and outlined variants. I suppose pursuing support for that again would need to be a separate effort anyway; if we've collapsed these styles into the defaults, we can remove all mention of the upgraded modifier in docs and JS.

I'm particularly wondering why the height: 48px disappeared though.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I deleted all the upgraded CSS code since text-field wont be supporting CSS only.

@@ -186,7 +181,7 @@
margin-bottom: 4px;
}

.mdc-text-field--box + &,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a little nervous about changes like this that just remove --box because whereas --box only ever applied to one variant, mdc-text-field applies to every MDC text field (thus making the --outlined selector after this completely redundant). Are we sure this is what we want, or should there be exceptions to this?

We should check this for anything where --box specifically was removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was the only area where --box was removed and the .mdc-text-field part of it was left. This affects specifically the helper text that only the default and outlined variants have.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also I deleted the outlined line because both the outline and the default variant have the .mdc-text-field class

Remove the outlined css selector because both the outlined version and the default variant (box) will have the .mdc-text-field
@@ -207,12 +199,17 @@ apply these mixins with CSS selectors such as `.foo-text-field.mdc-text-field--i

> _NOTE_: the `mdc-line-ripple-color` mixin should be applied from the not focused class `foo-text-field:not(.mdc-text-field--focused)`).

#### Mixins for Text Field Box
#### Mixins for Text Field
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might still want to split this up... IIUC ink/label color are applicable to any text field, while the others are specific to the filled text field (i.e. they wouldn't make sense on an outlined text field).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I separated them into Mixings specific for Filled Text Fields and All text fields


pointer-events: none;

.mdc-text-field__input {
border-bottom: 1px dotted;
// border-bottom-width: 1px;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this selector entirely if the styles are going away

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Completely right, I forgot to delete the commented code. Got it!

line-height: 1.15;
pointer-events: none;
text-overflow: clip;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand why these 4 styles were added - especially pointer-events: auto, didn't we recently intentionally set that to none to avoid the label stealing clicks from the input?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am trying to recreate the same effects that the text fields had before and so since more CSS was added in to the default .mdc-text-field I added styles to counteract the changes. However, Pointer-events actually does not counteract anything so i took that one out.

@@ -176,12 +178,16 @@
}

@mixin mdc-text-field-dense_ {
// NOTE: This is an eyeball'd approximation of what's in the mocks.
@include mdc-floating-label-float-position(110%, 0%, $mdc-text-field-dense-label-scale);
@include mdc-floating-label-float-position($mdc-text-field-dense-label-position-y, 0%, $mdc-text-field-dense-label-scale);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was changed from 110% to 70%?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

110% was the value for the variant being deprecated and the new default has a value of 70%. The only two variants this affects is the outlined and the "box" however the outlined has its own value in dense.

cursor: text;
overflow: hidden;
// Force the label into its own layer to prevent to prevent visible layer promotion adjustments
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"to prevent" is repeated

Also, this sounds like something that should be a separate fix, not in this PR...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can create a PR for that.

@include mdc-rtl-reflexive-position(left, 16px);

position: absolute;
bottom: 20px;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit confused why this was moved to a common mixin used for both filled and outlined text fields, if it was formerly specific to outlined?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was specified in the outlined mixin but actually it was used in both the box variant and the outlined.

&:not(.mdc-text-field--textarea) {
@include mdc-states-base-color(transparent);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm seeing states overridden to transparent several places in this file. I would sooner add :not selectors to our application of states styles than override it everywhere else (which will create far more styles in the output CSS; try npm run build and see). Is there a reason you didn't do that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think per our conversation its better to not have them too specific for the user to be able to customize it?

@@ -473,6 +413,8 @@
// to position the label within the bounds of the inset padding.
@include mdc-floating-label-float-position($mdc-text-field-textarea-label-position-y, 0%, $mdc-text-field-textarea-label-scale);
@include mdc-floating-label-shake-animation(textarea);
@include mdc-states-base-color(transparent);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See previous comment RE excluding selectors for states styles rather than overriding

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as before.

height: auto;
align-self: auto;
box-sizing: content-box;
height: 30px;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am confused by why this is changed

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possibly related: this screenshot diff I took of part of the page that otherwise didn't change

(Also notice the label position changed)

image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesnt seem to show a difference in my comparison with master. Will follow up with you

@kfranqueiro
Copy link
Contributor

This is also definitely a bug:

image


Mixin | Description
--- | ---
`mdc-text-field-box-corner-radius($radius)` | Customizes the border radius for the text field box variant.
`mdc-text-field-box-fill-color($color)` | Customizes the background color of the text field box.
`mdc-text-field-ink-color($color)` | Customizes the text entered into the text field.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Customizes the color of the text..."

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it!

border: none;
overflow: visible;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you explain what this does in the context of the outlined textfield and why it's necessary to make the content overflow visible?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In default, overflow is set to visible. When moving the Box variant to the new default it made overflow to hidden in the mdc-text-field class. It is necessary to set it to visible because when the label floats to the border of the box if it was not visible then the top half of the text would be cut.

@codecov-io
Copy link

codecov-io commented Jun 21, 2018

Codecov Report

Merging #2859 into master will increase coverage by 0.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2859      +/-   ##
==========================================
+ Coverage   98.37%   98.39%   +0.01%     
==========================================
  Files         123      123              
  Lines        5185     5185              
  Branches      639      639              
==========================================
+ Hits         5101     5102       +1     
+ Misses         84       83       -1
Impacted Files Coverage Δ
packages/mdc-textfield/constants.js 100% <ø> (ø) ⬆️
packages/mdc-textfield/index.js 93.78% <100%> (+0.62%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5007604...6989b93. Read the comment docs.

@googlebot
Copy link

So there's good news and bad news.

👍 The good news is that everyone that needs to sign a CLA (the pull request submitter and all commit authors) have done so. Everything is all good there.

😕 The bad news is that it appears that one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that here in the pull request.

Note to project maintainer: This is a terminal state, meaning the cla/google commit status will not change from this state. It's up to you to confirm consent of the commit author(s) and merge this pull request when appropriate.

@kfranqueiro
Copy link
Contributor

Something went wrong the last time this branch was synced. I'm adding the do-not-merge label until that's sorted out.

@williamernest
Copy link
Contributor

cursor: auto;
}
// stylelint-enable plugin/selector-bem-pattern
}

.mdc-floating-label {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm pretty sure all of these styles except for pointer-events: none; are now redundant with styles in the mdc-floating-label package.

Also, there's lint complaints on this line.

 112:1  ✖  Invalid component selector ".mdc-floating-label"                                                                                  plugin/selector-bem-pattern
 112:1  ✖  Expected selector ".mdc-floating-label" to come before selector ".mdc-text-field__input:-webkit-autofill + .mdc-floating-label"   no-descending-specificity

@@ -202,12 +201,23 @@ apply these mixins with CSS selectors such as `.foo-text-field.mdc-text-field--i

> _NOTE_: the `mdc-line-ripple-color` mixin should be applied from the not focused class `foo-text-field:not(.mdc-text-field--focused)`).

#### Mixins for Text Field Box
#### Mixins for all Text Field
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This heading doesn't seem quite accurate... at the very least, the label color mixin is only applicable to filled/outlined, not full-width / textarea (which don't use floating label).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The label color mixin applies to fullwidth and textarea.

@@ -800,7 +800,7 @@ <h3 class="mdc-typography--headline5 demo-component-section__heading">
</p>
</figure>
<figure class="demo-text-field-wrapper">
<div class="mdc-text-field mdc-text-field--box demo-text-field">
<div class="mdc-text-field demo-text-field">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The input and helper text under this text field still has an id that says box, do we want to update that?


// Floating Label
@include mdc-text-field-floating-label_;
// The following mixins will be removed after select is updated to default to the box.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand this comment or the shake-animation/keyframes taking text-field-box as an identifier. The mdc-select package doesn't depend on mdc-text-field at all, so what is this doing? The only reference I see to this within Select's own styles is with text-field-outlined.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment is stating that this isn't being updated until the floating-label is updated after the select. Updating these requires me to change things in the floating-label package, which is not within the scope of this PR.

@mdc-web-bot
Copy link
Collaborator

🤖 Beep boop!

Screenshot test report 🚦

144 screenshots changed from master on commit a38eb43:

Details

144 Changed:

@mdc-web-bot
Copy link
Collaborator

🤖 Beep boop!

Screenshot test report 🚦

144 screenshots changed from master on commit e4a08c8:

Details

144 Changed:

@williamernest
Copy link
Contributor

williamernest commented Aug 23, 2018

No, it wasn't using the correct class for height/width in the golden.

@williamernest williamernest dismissed stale reviews from patrickrodee and bonniezhou August 23, 2018 17:41

Stale review

@mdc-web-bot
Copy link
Collaborator

🤖 Beep boop!

Screenshot test report 🚦

144 screenshots changed from master on commit 6989b93:

Details

144 Changed:

@williamernest williamernest merged commit 01b6be7 into master Aug 23, 2018
@williamernest williamernest deleted the text-field/box-default branch August 23, 2018 17:58
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.

9 participants