Skip to content

Commit 23935db

Browse files
committed
fix(input): begin fixing notch adjustment
1 parent e3e1687 commit 23935db

File tree

2 files changed

+31
-6
lines changed

2 files changed

+31
-6
lines changed

core/src/components/input/input.md.outline.scss

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,9 @@
6262

6363
:host(.input-fill-outline.input-label-placement-stacked) .label-text-wrapper,
6464
:host(.input-fill-outline.input-label-placement-floating) .label-text-wrapper {
65-
@include transform-origin(center, top);
65+
@include transform-origin(start, top);
66+
67+
position: absolute;
6668
}
6769

6870
/**
@@ -87,6 +89,21 @@
8789
@include margin(0);
8890
}
8991

92+
/**
93+
* This element ensures that the notch used
94+
* the size of the scaled text so that the
95+
* border cut out is the correct width.
96+
* The text in this element should not
97+
* be interactive.
98+
*/
99+
:host(.input-fill-outline) .spacer {
100+
font-size: calc(1em * 0.75);
101+
102+
opacity: 0;
103+
104+
padding-right: 8px;
105+
}
106+
90107
/**
91108
* This ensures that the input does not
92109
* overlap the floating label while still
@@ -132,7 +149,15 @@
132149
@include border-radius(var(--border-radius), 0px, 0px, var(--border-radius));
133150
@include border(null, null, null, var(--border-width) var(--border-style) var(--border-color));
134151

135-
width: 12px;
152+
/**
153+
* There should be spacing between the translated text
154+
* and .input-outline-start. However, we can't add this
155+
* spacing onto the notch because it would cause the
156+
* label to look like it is not aligned with the
157+
* text input. Instead, we subtract a few pixels from
158+
* this element.
159+
*/
160+
width: calc(var(--padding-start) - 4px);
136161
}
137162

138163
/**

core/src/components/input/input.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -572,9 +572,7 @@ export class Input implements ComponentInterface {
572572
* when fill="outline".
573573
*/
574574
private renderLabelContainer() {
575-
const { labelPlacement } = this;
576575
const hasOutlineFill = this.fill === 'outline';
577-
const needsNotch = labelPlacement === 'floating' || labelPlacement === 'stacked';
578576

579577
if (hasOutlineFill) {
580578
/**
@@ -590,10 +588,12 @@ export class Input implements ComponentInterface {
590588
return [
591589
<div class="input-outline-container">
592590
<div class="input-outline-start"></div>
593-
<div class="input-outline-notch">{needsNotch && this.renderLabel()}</div>
591+
<div class="input-outline-notch">
592+
<div class="spacer">{this.label}</div>
593+
</div>
594594
<div class="input-outline-end"></div>
595595
</div>,
596-
!needsNotch && this.renderLabel(),
596+
this.renderLabel(),
597597
];
598598
}
599599

0 commit comments

Comments
 (0)