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

Commit 6129f45

Browse files
authored
fix(text-field): Make outline visibility directly linked to floating labels (#2073)
1 parent 04a6ee6 commit 6129f45

File tree

2 files changed

+13
-19
lines changed

2 files changed

+13
-19
lines changed

packages/mdc-textfield/_mixins.scss

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -195,14 +195,6 @@
195195
}
196196

197197
@mixin mdc-text-field-outlined-focused_ {
198-
.mdc-text-field__idle-outline {
199-
opacity: 0;
200-
}
201-
202-
.mdc-text-field__outline {
203-
opacity: 1;
204-
}
205-
206198
.mdc-text-field__outline-path {
207199
stroke-width: 2px;
208200
}
@@ -237,8 +229,6 @@
237229
height: 56px;
238230
border: none;
239231

240-
// stylelint-disable plugin/selector-bem-pattern
241-
242232
.mdc-text-field__input {
243233
display: flex;
244234
height: 30px;
@@ -260,22 +250,14 @@
260250
z-index: 2;
261251
}
262252

263-
.mdc-text-field__label--float-above ~ .mdc-text-field__idle-outline {
264-
opacity: 0;
265-
}
266-
253+
// stylelint-disable plugin/selector-bem-pattern
267254
.mdc-text-field__input:hover ~ .mdc-text-field__idle-outline {
268255
border: 1px solid;
269256
}
270257

271258
.mdc-text-field__icon:hover ~ .mdc-text-field__idle-outline {
272259
border: 1px solid $mdc-text-field-outlined-hover-border;
273260
}
274-
275-
.mdc-text-field__label--float-above ~ .mdc-text-field__outline {
276-
opacity: 1;
277-
}
278-
279261
// stylelint-enable plugin/selector-bem-pattern
280262
}
281263

packages/mdc-textfield/mdc-text-field.scss

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,3 +255,15 @@
255255
.mdc-text-field--textarea.mdc-text-field--disabled {
256256
@include mdc-text-field-textarea-disabled_;
257257
}
258+
259+
// Never show the idle outline when the label is floating, otherwise the label
260+
// will collide with the idle outline.
261+
.mdc-text-field__label--float-above ~ .mdc-text-field__idle-outline {
262+
opacity: 0;
263+
}
264+
265+
// Show the outline when the label is floating, since the outline has a
266+
// notch for the label to fit into.
267+
.mdc-text-field__label--float-above ~ .mdc-text-field__outline {
268+
opacity: 1;
269+
}

0 commit comments

Comments
 (0)