Skip to content

Commit d53fb29

Browse files
refactor(item): remove deprecated highlight variables used with legacy form controls (#29055)
Issue number: internal --------- ## What is the current behavior? In Ionic Framework v7, we [simplified the form control syntax](https://ionic.io/blog/ionic-7-is-here#simplified-form-control-syntax), eliminating the requirement to place form controls inside of an `ion-item`. We ensured backwards compatibility by introducing a `legacy` property for the form controls and keeping, but deprecating, the following CSS variables on item: ```css --highlight-color-focused --highlight-color-invalid --highlight-color-valid --highlight-height ``` While this was supported in v7, console warnings were logged to notify developers that they needed to update to the modern syntax if they were using form controls in an item for the best accessibility experience. ## What is the new behavior? Removes the `--highlight-color-focused`, `--highlight-color-invalid`, `--highlight-color-valid`, and `--highlight-height` variables from item. ## Does this introduce a breaking change? - [x] Yes - [ ] No Steps taken to mitigate this breaking change: 1. Developers have had console warnings when using the legacy syntax since the v7 release and the variables were marked as `deprecated`. 2. The removal of these CSS variables has been documented in the Breaking Changes document with a link to the migration guides for the affected form controls. BREAKING CHANGE: The following CSS variables have been removed from item: `--highlight-height`, `--highlight-color-focused`, `--highlight-color-valid`, and `--highlight-color-invalid`. These variables were used on the bottom border highlight of an item when the form control inside of that item was focused. The form control syntax was [simplified in v7](https://ionic.io/blog/ionic-7-is-here#simplified-form-control-syntax) so that inputs, selects, and textareas would no longer be required to be used inside of an item. If you have not yet migrated to the modern form control syntax, migration guides for each of the form controls that added a highlight to item can be found below: - [Input migration documentation](https://ionicframework.com/docs/api/input#migrating-from-legacy-input-syntax) - [Select migration documentation](https://ionicframework.com/docs/api/select#migrating-from-legacy-select-syntax) - [Textarea migration documentation](https://ionicframework.com/docs/api/textarea#migrating-from-legacy-textarea-syntax) The highlight variables should then be moved from the item to the form control: ```diff - ion-item { + ion-input, + ion-textarea, + ion-select { --highlight-color-focused: purple; --highlight-color-valid: blue; --highlight-color-invalid: orange; --highlight-height: 6px; } ``` > [!NOTE] > The input and textarea components are scoped, which means they will automatically scope their CSS by appending each of the styles with an additional class at runtime. Overriding scoped selectors in CSS requires a [higher specificity](https://developer.mozilla.org/en-US/docs/Web/CSS/Specificity) selector. Targeting the `ion-input` or `ion-textarea` for customization will not work; therefore we recommend adding a class and customizing it that way. --------- Co-authored-by: Sean Perkins <[email protected]>
1 parent 03d2670 commit d53fb29

File tree

10 files changed

+54
-211
lines changed

10 files changed

+54
-211
lines changed

BREAKING.md

Lines changed: 50 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ This is a comprehensive list of the breaking changes introduced in the major ver
2121
- [Checkbox](#version-8x-checkbox)
2222
- [Content](#version-8x-content)
2323
- [Datetime](#version-8x-datetime)
24-
- [Item](#version-8x-item)
2524
- [Input](#version-8x-input)
2625
- [Item](#version-8x-item)
2726
- [Modal](#version-8x-modal)
@@ -138,6 +137,7 @@ Developers who had previously chosen dynamic font scaling by activating it in th
138137
Developers who want to disable dynamic font scaling can set `--ion-dynamic-font: initial;` in their global stylesheets. However, this is not recommended because it may introduce accessibility challenges for users who depend on enlarged font sizes.
139138

140139
For more information on the dynamic font, refer to the [Dynamic Font Scaling documentation](https://ionicframework.com/docs/layout/dynamic-font-scaling).
140+
141141
<h2 id="version-8x-components">Components</h2>
142142

143143
<h4 id="version-8x-button">Button</h4>
@@ -163,23 +163,66 @@ For more information on the dynamic font, refer to the [Dynamic Font Scaling doc
163163
+ background: red;
164164
}
165165
```
166+
167+
<h4 id="version-8x-input">Input</h4>
168+
169+
- `size` has been removed from the `ion-input` component. Developers should use CSS to specify the visible width of the input.
170+
- `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.
171+
- 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).
172+
166173
<h4 id="version-8x-item">Item</h4>
167174

168175
- The `helper` slot has been removed. Developers should use the `helperText` property on `ion-input` and `ion-textarea`.
169176
- The `error` slot has been removed. Developers should use the `errorText` property on `ion-input` and `ion-textarea`.
170177
- Counter functionality has been removed including the `counter` and `counterFormatter` properties. Developers should use the properties of the same name on `ion-input` and `ion-textarea`.
171178
- The `fill` property has been removed. Developers should use the property of the same name on `ion-input`, `ion-select`, and `ion-textarea`.
172179
- The `shape` property has been removed. Developers should use the property of the same name on `ion-input`, `ion-select`, and `ion-textarea`.
180+
- Item no longer automatically delegates focus to the first focusable element. While most developers should not need to make any changes to account for this update, usages of `ion-item` with interactive elements such as form controls (inputs, textareas, etc) should be evaluated to verify that interactions still work as expected.
173181

174-
<h4 id="version-8x-input">Input</h4>
182+
<h5>CSS variables</h4>
175183

176-
- `size` has been removed from the `ion-input` component. Developers should use CSS to specify the visible width of the input.
177-
- `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.
178-
- 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).
184+
The following deprecated CSS variables have been removed: `--highlight-height`, `--highlight-color-focused`, `--highlight-color-valid`, and `--highlight-color-invalid`. These variables were used on the bottom border highlight of an item when the form control inside of that item was focused. The form control syntax was [simplified in v7](https://ionic.io/blog/ionic-7-is-here#simplified-form-control-syntax) so that inputs, selects, and textareas would no longer be required to be used inside of an item.
179185

180-
<h4 id="version-8x-item">Item</h4>
186+
If you have not yet migrated to the modern form control syntax, migration guides for each of the form controls that added a highlight to item can be found below:
187+
- [Input migration documentation](https://ionicframework.com/docs/api/input#migrating-from-legacy-input-syntax)
188+
- [Select migration documentation](https://ionicframework.com/docs/api/select#migrating-from-legacy-select-syntax)
189+
- [Textarea migration documentation](https://ionicframework.com/docs/api/textarea#migrating-from-legacy-textarea-syntax)
181190

182-
- Item no longer automatically delegates focus to the first focusable element. While most developers should not need to make any changes to account for this update, usages of `ion-item` with interactive elements such as form controls (inputs, textareas, etc) should be evaluated to verify that interactions still work as expected.
191+
Once all form controls are using the modern syntax, the same variables can be used to customize them from the form control itself:
192+
193+
| Name | Description |
194+
| ----------------------------| ----------------------------------------|
195+
| `--highlight-color-focused` | The color of the highlight when focused |
196+
| `--highlight-color-invalid` | The color of the highlight when invalid |
197+
| `--highlight-color-valid` | The color of the highlight when valid |
198+
| `--highlight-height` | The height of the highlight indicator |
199+
200+
The following styles for item:
201+
202+
```css
203+
ion-item {
204+
--highlight-color-focused: purple;
205+
--highlight-color-valid: blue;
206+
--highlight-color-invalid: orange;
207+
--highlight-height: 6px;
208+
}
209+
```
210+
211+
will instead be applied on the form controls:
212+
213+
```css
214+
ion-input,
215+
ion-textarea,
216+
ion-select {
217+
--highlight-color-focused: purple;
218+
--highlight-color-valid: blue;
219+
--highlight-color-invalid: orange;
220+
--highlight-height: 6px;
221+
}
222+
```
223+
224+
> [!NOTE]
225+
> The input and textarea components are scoped, which means they will automatically scope their CSS by appending each of the styles with an additional class at runtime. Overriding scoped selectors in CSS requires a [higher specificity](https://developer.mozilla.org/en-US/docs/Web/CSS/Specificity) selector. Targeting the `ion-input` or `ion-textarea` for customization will not work; therefore we recommend adding a class and customizing it that way.
183226
184227
<h4 id="version-8x-modal">Modal</h4>
185228

core/api.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -639,10 +639,6 @@ ion-item,css-prop,--color-hover
639639
ion-item,css-prop,--detail-icon-color
640640
ion-item,css-prop,--detail-icon-font-size
641641
ion-item,css-prop,--detail-icon-opacity
642-
ion-item,css-prop,--highlight-color-focused
643-
ion-item,css-prop,--highlight-color-invalid
644-
ion-item,css-prop,--highlight-color-valid
645-
ion-item,css-prop,--highlight-height
646642
ion-item,css-prop,--inner-border-width
647643
ion-item,css-prop,--inner-box-shadow
648644
ion-item,css-prop,--inner-padding-bottom

core/src/components/item/item.ios.scss

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,6 @@
2929
--background-hover-opacity: .04;
3030
--border-color: #{$item-ios-border-bottom-color};
3131
--color: #{$item-ios-color};
32-
--highlight-height: 0px;
33-
--highlight-color-focused: #{$item-ios-input-highlight-color};
34-
--highlight-color-valid: #{$item-ios-input-highlight-color-valid};
35-
--highlight-color-invalid: #{$item-ios-input-highlight-color-invalid};
3632

3733
font-size: $item-ios-font-size;
3834
}
@@ -63,24 +59,15 @@
6359
// iOS Item Lines
6460
// --------------------------------------------------
6561

66-
// Default input items have an inset border
67-
:host(.item-interactive) {
68-
--show-full-highlight: 0;
69-
--show-inset-highlight: 1;
70-
}
7162

7263
// Full lines - apply the border to the item
7364
// Inset lines - apply the border to the item inner
7465
:host(.item-lines-full) {
7566
--border-width: #{0px 0px $item-ios-border-bottom-width 0px};
76-
--show-full-highlight: 1;
77-
--show-inset-highlight: 0;
7867
}
7968

8069
:host(.item-lines-inset) {
8170
--inner-border-width: #{0px 0px $item-ios-border-bottom-width 0px};
82-
--show-full-highlight: 0;
83-
--show-inset-highlight: 1;
8471
}
8572

8673
// Full lines - remove the border from the item inner (inset list items)
@@ -89,28 +76,13 @@
8976
:host(.item-lines-inset),
9077
:host(.item-lines-none) {
9178
--border-width: 0px;
92-
--show-full-highlight: 0;
9379
}
9480

9581
:host(.item-lines-full),
9682
:host(.item-lines-none) {
9783
--inner-border-width: 0px;
98-
--show-inset-highlight: 0;
99-
}
100-
101-
.item-highlight,
102-
.item-inner-highlight {
103-
transition: none;
10484
}
10585

106-
:host(.item-has-focus) .item-inner-highlight,
107-
:host(.item-has-focus) .item-highlight {
108-
border-top: none;
109-
border-right: none;
110-
border-left: none;
111-
}
112-
113-
11486
// iOS Item Slots
11587
// --------------------------------------------------
11688

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

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,6 @@ $item-ios-border-bottom-style: solid !default;
5757
/// @prop - Border bottom color for the item when lines are displayed
5858
$item-ios-border-bottom-color: $item-ios-border-color !default;
5959

60-
/// @prop - Color of the item input highlight
61-
$item-ios-input-highlight-color: ion-color(primary, base) !default;
62-
63-
/// @prop - Color of the item input highlight when valid
64-
$item-ios-input-highlight-color-valid: ion-color(success, base) !default;
65-
66-
/// @prop - Color of the item input highlight when invalid
67-
$item-ios-input-highlight-color-invalid: ion-color(danger, base) !default;
68-
6960

7061
// Item Slots
7162
// --------------------------------------------------

core/src/components/item/item.md.scss

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,6 @@
2121
--padding-start: #{$item-md-padding-start};
2222
--inner-padding-end: #{$item-md-padding-end};
2323
--inner-border-width: #{0 0 $item-md-border-bottom-width 0};
24-
--highlight-height: 1px;
25-
--highlight-color-focused: #{$item-md-input-highlight-color};
26-
--highlight-color-valid: #{$item-md-input-highlight-color-valid};
27-
--highlight-color-invalid: #{$item-md-input-highlight-color-invalid};
2824

2925
font-size: dynamic-font($item-md-font-size);
3026
font-weight: normal;
@@ -41,33 +37,23 @@
4137
}
4238
}
4339

44-
:host(.item-has-focus) .item-native {
45-
caret-color: var(--highlight-background);
46-
}
47-
4840
// Material Design Item Lines
4941
// --------------------------------------------------
5042

5143
// Default input items have a full border
5244
:host(.item-interactive) {
5345
--border-width: #{0 0 $item-md-border-bottom-width 0};
5446
--inner-border-width: 0;
55-
--show-full-highlight: 1;
56-
--show-inset-highlight: 0;
5747
}
5848

5949
// Full lines - apply the border to the item
6050
// Inset lines - apply the border to the item inner
6151
:host(.item-lines-full) {
6252
--border-width: #{0 0 $item-md-border-bottom-width 0};
63-
--show-full-highlight: 1;
64-
--show-inset-highlight: 0;
6553
}
6654

6755
:host(.item-lines-inset) {
6856
--inner-border-width: #{0 0 $item-md-border-bottom-width 0};
69-
--show-full-highlight: 0;
70-
--show-inset-highlight: 1;
7157
}
7258

7359
// Full lines - remove the border from the item inner (inset list items)
@@ -76,13 +62,11 @@
7662
:host(.item-lines-inset),
7763
:host(.item-lines-none) {
7864
--border-width: 0;
79-
--show-full-highlight: 0;
8065
}
8166

8267
:host(.item-lines-full),
8368
:host(.item-lines-none) {
8469
--inner-border-width: 0;
85-
--show-inset-highlight: 0;
8670
}
8771

8872
// Material Design Multi-line Item
@@ -247,14 +231,3 @@
247231
:host(.item-has-focus:not(.ion-color)) ::slotted(.label-floating) {
248232
color: $label-md-text-color-focused;
249233
}
250-
251-
// Material Design Inputs: Highlight Color
252-
// --------------------------------------------------
253-
254-
:host(.ion-color) {
255-
--highlight-color-focused: #{current-color(contrast)};
256-
}
257-
258-
:host(.item-label-color) {
259-
--highlight-color-focused: #{current-color(base)};
260-
}

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

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,6 @@ $item-md-border-bottom-style: solid !default;
4242
/// @prop - Border bottom color for the item when lines are displayed
4343
$item-md-border-bottom-color: $item-md-border-color !default;
4444

45-
// Item Input
46-
// --------------------------------------------------
47-
48-
/// @prop - Color of the item input highlight
49-
$item-md-input-highlight-color: ion-color(primary, base) !default;
50-
51-
/// @prop - Color of the item input highlight when valid
52-
$item-md-input-highlight-color-valid: ion-color(success, base) !default;
53-
54-
/// @prop - Color of the item input highlight when invalid
55-
$item-md-input-highlight-color-invalid: ion-color(danger, base) !default;
56-
5745
// Item Label
5846
// --------------------------------------------------
5947

0 commit comments

Comments
 (0)