Skip to content

Commit 56a6e70

Browse files
authored
fix(input-group): refine label positioning and transition logic in material theme (#1739)
1 parent f1032a6 commit 56a6e70

File tree

2 files changed

+17
-19
lines changed

2 files changed

+17
-19
lines changed

src/components/input/themes/shared/input.material.scss

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@ $active-border-width: rem(2px) !default;
88
$fs: rem(16px) !default;
99

1010
%label {
11-
--label-position: #{sizable(18px, 22px, 26px)};
12-
13-
transform: translateY(calc(var(--label-position) * -1));
11+
translate: 0 calc(var(--label-position) * -1);
1412
}
1513

1614
%floated-styles {
@@ -70,11 +68,12 @@ input:placeholder-shown + [part='notch'] [part='label'],
7068
color: var-get($theme, 'idle-secondary-color');
7169
transition:
7270
transform 150ms cubic-bezier(0.4, 0, 0.2, 1),
71+
translate 150ms cubic-bezier(0.4, 0, 0.2, 1),
7372
color 150ms cubic-bezier(0.4, 0, 0.2, 1),
7473
font-size 150ms cubic-bezier(0.4, 0, 0.2, 1);
7574
text-overflow: ellipsis;
7675
overflow: hidden;
77-
will-change: font-size, color, transform;
76+
will-change: font-size, color, transform, translate;
7877
}
7978

8079
[part^='container'] {
@@ -149,7 +148,7 @@ input:placeholder-shown + [part='notch'] [part='label'],
149148
:host([readonly]:not([outlined]):focus-within) {
150149
:not([part~='filled']) {
151150
input:not(:placeholder-shown) + [part='notch'] [part='label'] {
152-
transform: translate(0);
151+
translate: 0;
153152
font-size: initial;
154153
}
155154
}
@@ -201,7 +200,7 @@ input:placeholder-shown + [part='notch'] [part='label'],
201200

202201
input:placeholder-shown + [part='notch'] [part='label'],
203202
[part~='filled'] + [part='notch'] [part='label'] {
204-
transform: translateY(-73%);
203+
translate: 0 -73%;
205204
}
206205
}
207206

@@ -247,7 +246,7 @@ input:placeholder-shown + [part='notch'] [part='label'],
247246
}
248247

249248
[part='notch'] [part='label'] {
250-
transform: translateY(-73%);
249+
translate: 0 -73%;
251250
}
252251
}
253252

@@ -310,16 +309,11 @@ input:placeholder-shown + [part='notch'] [part='label'],
310309
padding-top: rem(20px);
311310
padding-bottom: rem(6px);
312311
}
313-
314-
input:placeholder-shown + [part='notch'] [part='label'],
315-
[part~='filled'] + [part='notch'] [part='label'] {
316-
transform: translateY(-73%);
317-
}
318312
}
319313

320314
:host([outlined][type='search']:focus-within) {
321315
[part='notch'] [part='label'] {
322-
transform: translateY(-73%);
316+
translate: 0 -73%;
323317
}
324318
}
325319

@@ -392,6 +386,8 @@ input:placeholder-shown + [part='notch'] [part='label'],
392386
}
393387

394388
:host([outlined]) {
389+
--label-position: calc((#{var-get($theme, 'size')} / 2) - (#{$idle-border-width}));
390+
395391
[part='notch'] {
396392
border: {
397393
width: $idle-border-width;
@@ -436,7 +432,7 @@ input:placeholder-shown + [part='notch'] [part='label'],
436432
:host(:not([type='search'])[readonly][outlined]:focus-within) {
437433
:not([part~='filled']) {
438434
input:not(:placeholder-shown) + [part='notch'] [part='label'] {
439-
transform: translate(0);
435+
translate: 0;
440436
font-size: initial;
441437
}
442438

src/components/textarea/themes/shared/textarea.material.scss

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,25 +42,25 @@ textarea {
4242
transform 150ms cubic-bezier(.4, 0, .2, 1),
4343
color 150ms cubic-bezier(.4, 0, .2, 1),
4444
font-size 150ms cubic-bezier(.4, 0, .2, 1);
45-
will-change: transform;
45+
will-change: transform, translate;
4646
}
4747

4848
%label-filled {
4949
@include type-style('caption');
5050

51-
transform: translateY(0);
51+
translate: 0;
5252
inset-block-start: calc(#{$input-top-padding} / 4);
5353
}
5454

5555
%label-outlined-filled {
5656
@include type-style('caption') {
57-
margin-block-end: auto;
57+
margin-block-end: 0;
5858
};
5959

6060
display: inline-block;
6161
position: relative;
6262
inset-block: 0;
63-
transform: translateY(-50%);
63+
translate: 0 calc(var(--textarea-label-position) * -1);
6464
padding-inline-end: 0;
6565
}
6666

@@ -195,7 +195,7 @@ textarea {
195195

196196
[part='notch'] {
197197
display: flex;
198-
align-items: center;
198+
align-items: flex-start;
199199
width: auto;
200200
min-width: 0;
201201
height: 100%;
@@ -230,6 +230,8 @@ textarea {
230230

231231
// Outlined Textarea
232232
:host([outlined]) {
233+
--textarea-label-position: calc(50% + (#{rem(1px)}));
234+
233235
align-items: initial;
234236
padding: 0;
235237
box-shadow: none;

0 commit comments

Comments
 (0)