Skip to content

Commit 76abf27

Browse files
refactor(input): remove legacy property and support for legacy syntax (#29017)
Issue number: internal --------- ## What is the current behavior? In Ionic Framework v7, we [simplified the input syntax](https://ionic.io/blog/ionic-7-is-here#simplified-form-control-syntax) so that it was no longer required to be placed inside of an `ion-item`. We maintained backwards compatibility by adding a `legacy` property which allowed it to continue to be styled properly when written in the following way: ```html <ion-item> <ion-label>Label</ion-label> <ion-input></ion-input> </ion-item> ``` While this was supported in v7, console warnings were logged to notify developers that they needed to update this syntax for the best accessibility experience. ## What is the new behavior? - Removes the `legacy` property and support for the legacy syntax. Developers should follow the [migration guide](https://ionicframework.com/docs/api/input#migrating-from-legacy-input-syntax) in the input documentation to update their apps. The new syntax requires a `label` or `aria-label` on `ion-input`: ```html <ion-item> <ion-input label="Label"></ion-input> </ion-item> ``` - Removes the legacy tests under under `input/test/legacy/` and all related screenshots - Removes the input usage from `item/test/a11y`, `item/test/counter`, `item/test/disabled`, `item/test/highlight`, `item/test/legacy/alignment`, `item/test/legacy/disabled`, `item/test/legacy/fill`, and `item/test/legacy/form` and all related screenshots if the test was removed ## Does this introduce a breaking change? - [x] Yes - [ ] No 1. Developers have had console warnings when using the legacy syntax since the v7 release. The migration guide for the new input syntax is outlined in the [Input documentation](https://ionicframework.com/docs/api/input#migrating-from-legacy-input-syntax). 2. This change has been documented in the Breaking Changes document with a link to the migration guide. BREAKING CHANGE: The `legacy` property and support for the legacy syntax, which involved placing an `ion-input` inside of an `ion-item` with an `ion-label`, have been removed from input. For more information on migrating from the legacy input syntax, refer to the [Input documentation](https://ionicframework.com/docs/api/input#migrating-from-legacy-input-syntax). --------- Co-authored-by: ionitron <[email protected]>
1 parent ca61e50 commit 76abf27

File tree

246 files changed

+9
-2868
lines changed

Some content is hidden

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

246 files changed

+9
-2868
lines changed

BREAKING.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ For more information on the dynamic font, refer to the [Dynamic Font Scaling doc
154154

155155
- `size` has been removed from the `ion-input` component. Developers should use CSS to specify the visible width of the input.
156156
- `accept` has been removed from the `ion-input` component. This was previously used in conjunction with the `type="file"`. However, the `file` value for `type` is not a valid value in Ionic Framework.
157+
- The `legacy` property and support for the legacy syntax, which involved placing an `ion-input` inside of an `ion-item` with an `ion-label`, have been removed. For more information on migrating from the legacy input syntax, refer to the [Input documentation](https://ionicframework.com/docs/api/input#migrating-from-legacy-input-syntax).
157158

158159
<h4 id="version-8x-nav">Nav</h4>
159160

core/api.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,6 @@ ion-input,prop,helperText,string | undefined,undefined,false,false
566566
ion-input,prop,inputmode,"decimal" | "email" | "none" | "numeric" | "search" | "tel" | "text" | "url" | undefined,undefined,false,false
567567
ion-input,prop,label,string | undefined,undefined,false,false
568568
ion-input,prop,labelPlacement,"end" | "fixed" | "floating" | "stacked" | "start",'start',false,false
569-
ion-input,prop,legacy,boolean | undefined,undefined,false,false
570569
ion-input,prop,max,number | string | undefined,undefined,false,false
571570
ion-input,prop,maxlength,number | undefined,undefined,false,false
572571
ion-input,prop,min,number | string | undefined,undefined,false,false

core/src/components.d.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1220,10 +1220,6 @@ export namespace Components {
12201220
* Where to place the label relative to the input. `"start"`: The label will appear to the left of the input in LTR and to the right in RTL. `"end"`: The label will appear to the right of the input in LTR and to the left in RTL. `"floating"`: The label will appear smaller and above the input when the input is focused or it has a value. Otherwise it will appear on top of the input. `"stacked"`: The label will appear smaller and above the input regardless even when the input is blurred or has no value. `"fixed"`: The label has the same behavior as `"start"` except it also has a fixed width. Long text will be truncated with ellipses ("...").
12211221
*/
12221222
"labelPlacement": 'start' | 'end' | 'floating' | 'stacked' | 'fixed';
1223-
/**
1224-
* Set the `legacy` property to `true` to forcibly use the legacy form control markup. Ionic will only opt components in to the modern form markup when they are using either the `aria-label` attribute or the `label` property. As a result, the `legacy` property should only be used as an escape hatch when you want to avoid this automatic opt-in behavior. Note that this property will be removed in an upcoming major release of Ionic, and all form components will be opted-in to using the modern form markup.
1225-
*/
1226-
"legacy"?: boolean;
12271223
/**
12281224
* The maximum value, which must not be less than its minimum (min attribute) value.
12291225
*/
@@ -5951,10 +5947,6 @@ declare namespace LocalJSX {
59515947
* Where to place the label relative to the input. `"start"`: The label will appear to the left of the input in LTR and to the right in RTL. `"end"`: The label will appear to the right of the input in LTR and to the left in RTL. `"floating"`: The label will appear smaller and above the input when the input is focused or it has a value. Otherwise it will appear on top of the input. `"stacked"`: The label will appear smaller and above the input regardless even when the input is blurred or has no value. `"fixed"`: The label has the same behavior as `"start"` except it also has a fixed width. Long text will be truncated with ellipses ("...").
59525948
*/
59535949
"labelPlacement"?: 'start' | 'end' | 'floating' | 'stacked' | 'fixed';
5954-
/**
5955-
* Set the `legacy` property to `true` to forcibly use the legacy form control markup. Ionic will only opt components in to the modern form markup when they are using either the `aria-label` attribute or the `label` property. As a result, the `legacy` property should only be used as an escape hatch when you want to avoid this automatic opt-in behavior. Note that this property will be removed in an upcoming major release of Ionic, and all form components will be opted-in to using the modern form markup.
5956-
*/
5957-
"legacy"?: boolean;
59585950
/**
59595951
* The maximum value, which must not be less than its minimum (min attribute) value.
59605952
*/

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

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,6 @@
88
font-size: $input-ios-font-size;
99
}
1010

11-
// TODO FW-2764 Remove this
12-
:host(.legacy-input) {
13-
--padding-top: #{$input-ios-padding-top};
14-
--padding-end: #{$input-ios-padding-end};
15-
--padding-bottom: #{$input-ios-padding-bottom};
16-
--padding-start: #{$input-ios-padding-start};
17-
}
18-
19-
:host-context(.item-label-stacked),
20-
:host-context(.item-label-floating) {
21-
--padding-top: 8px;
22-
--padding-bottom: 8px;
23-
--padding-start: 0px;
24-
}
25-
2611
.input-clear-icon ion-icon {
2712
width: 18px;
2813
height: 18px;
@@ -33,7 +18,6 @@
3318
// The input, label, helper text, char counter and placeholder
3419
// should use the same opacity and match the other form controls
3520

36-
:host(.legacy-input) .native-input[disabled],
3721
:host(.input-disabled) {
3822
opacity: #{$input-ios-disabled-opacity};
3923
}

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

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,5 @@
77
/// @prop - Font size of the input
88
$input-ios-font-size: inherit !default;
99

10-
/// @prop - Margin top of the input
11-
$input-ios-padding-top: $item-ios-padding-top !default;
12-
13-
/// @prop - Margin end of the input
14-
$input-ios-padding-end: ($item-ios-padding-end * 0.5) !default;
15-
16-
/// @prop - Margin bottom of the input
17-
$input-ios-padding-bottom: $item-ios-padding-bottom !default;
18-
19-
/// @prop - Margin start of the input
20-
$input-ios-padding-start: 0 !default;
21-
2210
/// @prop - The opacity of the input text, label, helper text, char counter and placeholder of a disabled input
2311
$input-ios-disabled-opacity: $form-control-ios-disabled-opacity !default;

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

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,6 @@
1414
font-size: $input-md-font-size;
1515
}
1616

17-
// TODO FW-2764 Remove this
18-
:host(.legacy-input) {
19-
--padding-top: #{$input-md-padding-top};
20-
--padding-end: #{$input-md-padding-end};
21-
--padding-bottom: #{$input-md-padding-bottom};
22-
--padding-start: #{$input-md-padding-start};
23-
}
24-
25-
:host-context(.item-label-stacked),
26-
:host-context(.item-label-floating) {
27-
--padding-top: 8px;
28-
--padding-bottom: 8px;
29-
--padding-start: 0;
30-
}
31-
3217
.input-clear-icon ion-icon {
3318
width: 22px;
3419
height: 22px;
@@ -39,7 +24,6 @@
3924
// The input, label, helper text, char counter and placeholder
4025
// should use the same opacity and match the other form controls
4126

42-
:host(.legacy-input) .native-input[disabled],
4327
:host(.input-disabled) {
4428
opacity: #{$input-md-disabled-opacity};
4529
}

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

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,6 @@
77
/// @prop - Font size of the input
88
$input-md-font-size: inherit !default;
99

10-
/// @prop - Margin top of the input
11-
$input-md-padding-top: 10px !default;
12-
13-
/// @prop - Margin end of the input
14-
$input-md-padding-end: 0 !default;
15-
16-
/// @prop - Margin bottom of the input
17-
$input-md-padding-bottom: 10px !default;
18-
19-
/// @prop - Margin start of the input
20-
$input-md-padding-start: ($item-md-padding-start * 0.5) !default;
21-
2210
/// @prop - The amount of whitespace to display on either side of the floating label
2311
$input-md-floating-label-padding: 4px !default;
2412

core/src/components/input/input.scss

Lines changed: 2 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@
5757

5858
width: 100%;
5959

60+
min-height: 44px;
61+
6062
/* stylelint-disable-next-line all */
6163
padding: 0 !important;
6264

@@ -67,47 +69,18 @@
6769
z-index: $z-index-item-input;
6870
}
6971

70-
// TODO FW-2764 Remove this
71-
:host(.legacy-input) {
72-
display: flex;
73-
74-
flex: 1;
75-
align-items: center;
76-
77-
background: var(--background);
78-
}
79-
80-
// TODO FW-2764 Remove this
81-
:host(.legacy-input) .native-input {
82-
@include padding(var(--padding-top), var(--padding-end), var(--padding-bottom), var(--padding-start));
83-
@include border-radius(var(--border-radius));
84-
}
85-
86-
:host-context(ion-item:not(.item-label):not(.item-has-modern-input)) {
87-
--padding-start: 0;
88-
}
89-
9072
:host-context(ion-item)[slot="start"],
9173
:host-context(ion-item)[slot="end"] {
9274
width: auto;
9375
}
9476

95-
// TODO FW-2764 Remove this
96-
:host(.legacy-input.ion-color) {
97-
color: current-color(base);
98-
}
99-
10077
:host(.ion-color) {
10178
--highlight-color-focused: #{current-color(base)};
10279
}
10380

10481
// Input Wrapper
10582
// ----------------------------------------------------------------
10683

107-
:host(:not(.legacy-input)) {
108-
min-height: 44px;
109-
}
110-
11184
/**
11285
* Since the label sits on top of the element,
11386
* the component needs to be taller otherwise the
@@ -206,11 +179,6 @@
206179
// Clear Input Icon
207180
// --------------------------------------------------
208181

209-
// TODO FW-2764 Remove this
210-
:host(.legacy-input) .input-clear-icon {
211-
@include margin(0);
212-
}
213-
214182
.input-clear-icon {
215183
@include margin(auto);
216184
@include padding(0);
@@ -256,37 +224,6 @@
256224
visibility: visible;
257225
}
258226

259-
260-
// Input Has focus
261-
// --------------------------------------------------
262-
263-
// TODO FW-2764 Remove this
264-
:host(.has-focus.legacy-input) {
265-
pointer-events: none;
266-
}
267-
268-
// TODO FW-2764 Remove this
269-
:host(.has-focus.legacy-input) input,
270-
:host(.has-focus.legacy-input) a,
271-
:host(.has-focus.legacy-input) button {
272-
pointer-events: auto;
273-
}
274-
275-
276-
// Item Floating: Placeholder
277-
// ----------------------------------------------------------------
278-
// When used with a floating item the placeholder should hide
279-
280-
:host-context(.item-label-floating.item-has-placeholder:not(.item-has-value)) {
281-
opacity: 0;
282-
}
283-
284-
:host-context(.item-label-floating.item-has-placeholder:not(.item-has-value).item-has-focus) {
285-
transition: opacity 0.15s cubic-bezier(0.4, 0, 0.2, 1);
286-
287-
opacity: 1;
288-
}
289-
290227
// Input Wrapper
291228
// ----------------------------------------------------------------
292229

0 commit comments

Comments
 (0)