Skip to content

Commit 97f9cb1

Browse files
committed
Revert "fix(input): floating label works correctly with long text and notch (#26252)"
This reverts commit 753ffda.
1 parent 753ffda commit 97f9cb1

File tree

93 files changed

+30
-284
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+30
-284
lines changed

core/src/components/input/input.ios.scss

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,3 @@
4848
:host(.input-label-placement-stacked) .input-wrapper {
4949
min-height: 56px;
5050
}
51-
52-
:host(.input-label-placement-stacked) .label-text-wrapper,
53-
:host(.input-label-placement-floating) .label-text-wrapper {
54-
max-width: 100%;
55-
}

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

Lines changed: 13 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
@import "./input.vars";
2-
31
// Input Fill: Outline
42
// ----------------------------------------------------------------
53

@@ -11,7 +9,7 @@
119
}
1210

1311
:host(.input-fill-outline.input-shape-round) {
14-
--border-radius: 28px;
12+
--border-radius: 9999px;
1513
--padding-start: 32px;
1614
--padding-end: 32px;
1715
}
@@ -64,15 +62,7 @@
6462

6563
:host(.input-fill-outline.input-label-placement-stacked) .label-text-wrapper,
6664
:host(.input-fill-outline.input-label-placement-floating) .label-text-wrapper {
67-
@include transform-origin(start, top);
68-
69-
position: absolute;
70-
71-
/**
72-
* Label text should not extend
73-
* beyond the bounds of the input.
74-
*/
75-
max-width: calc(100% - var(--padding-start) - var(--padding-end));
65+
@include transform-origin(center, top);
7666
}
7767

7868
/**
@@ -93,14 +83,8 @@
9383
:host(.has-value.input-fill-outline.input-label-placement-floating) .label-text-wrapper,
9484
:host(.input-fill-outline.input-label-placement-stacked) .label-text-wrapper,
9585
:host(.input-fill-outline.input-label-placement-stacked) .label-text-wrapper {
96-
@include transform(translateY(-32%), scale(#{$input-floating-label-scale}));
86+
@include transform(translateY(-32%), scale(.75));
9787
@include margin(0);
98-
99-
/**
100-
* Label text should not extend
101-
* beyond the bounds of the input.
102-
*/
103-
max-width: calc((100% - var(--padding-start) - var(--padding-end) - #{$input-md-floating-label-padding * 2}) / #{$input-floating-label-scale});
10488
}
10589

10690
/**
@@ -144,51 +128,20 @@
144128
border-bottom: var(--border-width) var(--border-style) var(--border-color);
145129
}
146130

147-
/**
148-
* Ensures long labels do not cause the notch to flow
149-
* out of bounds.
150-
*/
151-
:host(.input-fill-outline) .input-outline-notch {
152-
max-width: calc(100% - var(--padding-start) - var(--padding-end));
153-
}
154-
155-
/**
156-
* This element ensures that the notch used
157-
* the size of the scaled text so that the
158-
* border cut out is the correct width.
159-
* The text in this element should not
160-
* be interactive.
161-
*/
162-
:host(.input-fill-outline) .notch-spacer {
163-
/**
164-
* We need $input-md-floating-label-padding of padding on the right.
165-
* However, we also subtracted $input-md-floating-label-padding from
166-
* the width of .input-outline-start
167-
* to create space, so we need to take
168-
* that into consideration here.
169-
*/
170-
@include padding(null, #{$input-md-floating-label-padding * 2}, null, null);
171-
172-
font-size: calc(1em * #{$input-floating-label-scale});
173-
174-
opacity: 0;
175-
pointer-events: none;
176-
}
177-
178-
179131
:host(.input-fill-outline) .input-outline-start {
180132
@include border-radius(var(--border-radius), 0px, 0px, var(--border-radius));
181133
@include border(null, null, null, var(--border-width) var(--border-style) var(--border-color));
182134

183-
/**
184-
* There should be spacing between the translated text
185-
* and .input-outline-start. However, we can't add this
186-
* spacing onto the notch because it would cause the
187-
* label to look like it is not aligned with the
188-
* text input. Instead, we subtract a few pixels from
189-
* this element.
190-
*/
191-
width: calc(var(--padding-start) - #{$input-md-floating-label-padding});
135+
width: 12px;
136+
}
137+
138+
/**
139+
* When shape="round", the starting outline fragment
140+
* should appear with a pill shape.
141+
*/
142+
:host(.input-fill-outline.input-shape-round) .input-outline-start {
143+
@include border-radius(28px, 0px, 0px, 28px);
144+
width: 28px;
192145
}
193146

194147
:host(.input-fill-outline) .input-outline-end {

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

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
@import "./input.vars";
2-
31
// Input Fill: Solid
42
// ----------------------------------------------------------------
53

@@ -61,22 +59,3 @@
6159
*/
6260
@include border-radius(var(--border-radius), var(--border-radius), 0px, 0px);
6361
}
64-
65-
// Input Label
66-
// ----------------------------------------------------------------
67-
68-
:host(.input-fill-solid.input-label-placement-stacked) .label-text-wrapper,
69-
:host(.input-fill-solid.input-label-placement-floating) .label-text-wrapper {
70-
max-width: 100%;
71-
}
72-
73-
:host(.has-focus.input-fill-solid.input-label-placement-stacked) .label-text-wrapper,
74-
:host(.has-value.input-fill-solid.input-label-placement-stacked) .label-text-wrapper,
75-
:host(.has-focus.input-fill-solid.input-label-placement-floating) .label-text-wrapper,
76-
:host(.has-value.input-fill-solid.input-label-placement-floating) .label-text-wrapper {
77-
/**
78-
* Label text should not extend
79-
* beyond the bounds of the input.
80-
*/
81-
max-width: calc(100% / #{$input-floating-label-scale});
82-
}

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,3 @@ $input-md-inset-margin-bottom: ($item-md-padding-bottom * 0.5) !defau
7575

7676
/// @prop - Margin start of the inset input
7777
$input-md-inset-margin-start: $item-md-padding-start !default;
78-
79-
/// @prop - The amount of whitespace to display on either side of the floating label
80-
$input-md-floating-label-padding: 4px !default;

core/src/components/input/input.scss

Lines changed: 7 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -393,6 +393,13 @@
393393
// ----------------------------------------------------------------
394394

395395
.label-text-wrapper {
396+
/**
397+
* The margin between the label and
398+
* the input should be on the end
399+
* when the label sits at the start.
400+
*/
401+
@include margin(0, 8px, 0, 0);
402+
396403
/**
397404
* This causes the label to take up
398405
* the entire height of its container
@@ -402,16 +409,6 @@
402409

403410
align-items: center;
404411

405-
/**
406-
* Label text should not extend
407-
* beyond the bounds of the input.
408-
* However, we do not set the max
409-
* width to 100% because then
410-
* only the label would show and users
411-
* would not be able to see what they are typing.
412-
*/
413-
max-width: 200px;
414-
415412
transition: color 150ms cubic-bezier(.4, 0, .2, 1), transform 150ms cubic-bezier(.4, 0, .2, 1);
416413

417414
/**
@@ -463,15 +460,6 @@
463460
flex-direction: row;
464461
}
465462

466-
:host(.input-label-placement-start) .label-text-wrapper {
467-
/**
468-
* The margin between the label and
469-
* the input should be on the end
470-
* when the label sits at the start.
471-
*/
472-
@include margin(0, 8px, 0, 0);
473-
}
474-
475463
// Input Label Placement - End
476464
// ----------------------------------------------------------------
477465

@@ -495,15 +483,6 @@
495483
// Input Label Placement - Fixed
496484
// ----------------------------------------------------------------
497485

498-
:host(.input-label-placement-fixed) .label-text-wrapper {
499-
/**
500-
* The margin between the label and
501-
* the input should be on the end
502-
* when the label sits at the start.
503-
*/
504-
@include margin(0, 8px, 0, 0);
505-
}
506-
507486
/**
508487
* Label is on the left of the input in LTR and
509488
* on the right in RTL. Label also has a fixed width.
@@ -580,10 +559,4 @@
580559
:host(.has-focus.input-label-placement-floating) .label-text-wrapper,
581560
:host(.has-value.input-label-placement-floating) .label-text-wrapper {
582561
@include transform(translateY(50%), scale(.75));
583-
584-
/**
585-
* Label text should not extend
586-
* beyond the bounds of the input.
587-
*/
588-
max-width: calc(100% / #{$input-floating-label-scale});
589562
}

core/src/components/input/input.tsx

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

578579
if (hasOutlineFill) {
579580
/**
580581
* The outline fill has a special outline
581582
* that appears around the input and the label.
582-
* Certain stacked and floating label placements cause the
583+
* Certain label placements cause the
583584
* label to translate up and create a "cut out"
584-
* inside of that border by using the notch-spacer element.
585+
* inside of that border. When this happens, we need
586+
* to render the label inside of the input-outline-notch
587+
* element. Otherwise, we can render it as a sibling
588+
* of the outline container.
585589
*/
586590
return [
587591
<div class="input-outline-container">
588592
<div class="input-outline-start"></div>
589-
<div class="input-outline-notch">
590-
<div class="notch-spacer" aria-hidden="true">
591-
{this.label}
592-
</div>
593-
</div>
593+
<div class="input-outline-notch">{needsNotch && this.renderLabel()}</div>
594594
<div class="input-outline-end"></div>
595595
</div>,
596-
this.renderLabel(),
596+
!needsNotch && this.renderLabel(),
597597
];
598598
}
599599

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1 @@
11
@import "../../themes/ionic.globals";
2-
3-
/// @prop - How much to scale the floating label by
4-
$input-floating-label-scale: 0.75 !default;

core/src/components/input/test/fill/input.e2e.ts

Lines changed: 0 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -22,24 +22,6 @@ test.describe('input: fill', () => {
2222
const input = page.locator('ion-input');
2323
expect(await input.screenshot()).toMatchSnapshot(`input-fill-solid-${page.getSnapshotSettings()}.png`);
2424
});
25-
test('should render correctly with floating label', async ({ page }) => {
26-
await page.setContent(`
27-
<ion-input
28-
fill="solid"
29-
label="Email"
30-
label-placement="floating"
31-
32-
helper-text="Enter your email"
33-
maxlength="20"
34-
counter="true"
35-
></ion-input>
36-
`);
37-
38-
const input = page.locator('ion-input');
39-
expect(await input.screenshot()).toMatchSnapshot(
40-
`input-fill-solid-label-floating-${page.getSnapshotSettings()}.png`
41-
);
42-
});
4325
test('should not have visual regressions with shaped solid', async ({ page }) => {
4426
await page.setContent(`
4527
<ion-input
@@ -56,33 +38,6 @@ test.describe('input: fill', () => {
5638
const input = page.locator('ion-input');
5739
expect(await input.screenshot()).toMatchSnapshot(`input-fill-shaped-solid-${page.getSnapshotSettings()}.png`);
5840
});
59-
test('padding and border radius should be customizable', async ({ page }) => {
60-
await page.setContent(`
61-
<style>
62-
ion-input {
63-
--border-radius: 10px !important;
64-
--padding-start: 50px !important;
65-
--padding-end: 50px !important;
66-
}
67-
</style>
68-
69-
<ion-input
70-
shape="round"
71-
fill="solid"
72-
label="Email"
73-
label-placement="floating"
74-
75-
helper-text="Enter your email"
76-
maxlength="20"
77-
counter="true"
78-
></ion-input>
79-
`);
80-
81-
const input = page.locator('ion-input');
82-
expect(await input.screenshot()).toMatchSnapshot(
83-
`input-fill-shaped-solid-custom-${page.getSnapshotSettings()}.png`
84-
);
85-
});
8641
});
8742
test.describe('input: fill outline', () => {
8843
test('should not have visual regressions', async ({ page }) => {
@@ -100,24 +55,6 @@ test.describe('input: fill', () => {
10055
const input = page.locator('ion-input');
10156
expect(await input.screenshot()).toMatchSnapshot(`input-fill-outline-${page.getSnapshotSettings()}.png`);
10257
});
103-
test('should render correctly with floating label', async ({ page }) => {
104-
await page.setContent(`
105-
<ion-input
106-
fill="outline"
107-
label="Email"
108-
label-placement="floating"
109-
110-
helper-text="Enter your email"
111-
maxlength="20"
112-
counter="true"
113-
></ion-input>
114-
`);
115-
116-
const input = page.locator('ion-input');
117-
expect(await input.screenshot()).toMatchSnapshot(
118-
`input-fill-outline-label-floating-${page.getSnapshotSettings()}.png`
119-
);
120-
});
12158
test('should not have visual regressions with shaped outline', async ({ page }) => {
12259
await page.setContent(`
12360
<ion-input
@@ -134,32 +71,5 @@ test.describe('input: fill', () => {
13471
const input = page.locator('ion-input');
13572
expect(await input.screenshot()).toMatchSnapshot(`input-fill-shaped-outline-${page.getSnapshotSettings()}.png`);
13673
});
137-
test('padding and border radius should be customizable', async ({ page }) => {
138-
await page.setContent(`
139-
<style>
140-
ion-input {
141-
--border-radius: 10px !important;
142-
--padding-start: 50px !important;
143-
--padding-end: 50px !important;
144-
}
145-
</style>
146-
147-
<ion-input
148-
shape="round"
149-
fill="outline"
150-
label="Email"
151-
label-placement="floating"
152-
153-
helper-text="Enter your email"
154-
maxlength="20"
155-
counter="true"
156-
></ion-input>
157-
`);
158-
159-
const input = page.locator('ion-input');
160-
expect(await input.screenshot()).toMatchSnapshot(
161-
`input-fill-shaped-outline-custom-${page.getSnapshotSettings()}.png`
162-
);
163-
});
16474
});
16575
});
-13.5 KB
Binary file not shown.
-4.54 KB
Binary file not shown.

0 commit comments

Comments
 (0)