Skip to content

Commit fb5ae5b

Browse files
authored
refactor(checkbox): remove legacy property and support for legacy syntax (#29043)
BREAKING CHANGE: The `legacy` property and support for the legacy syntax, which involved placing an `ion-checkbox` inside of an `ion-item` with an `ion-label`, have been removed from checkbox. For more information on migrating from the legacy checkbox syntax, refer to the [Checkbox documentation](https://ionicframework.com/docs/api/checkbox#migrating-from-legacy-checkbox-syntax).
1 parent 6baf005 commit fb5ae5b

File tree

62 files changed

+19
-614
lines changed

Some content is hidden

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

62 files changed

+19
-614
lines changed

BREAKING.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ This is a comprehensive list of the breaking changes introduced in the major ver
1818
- [Global Styles](#version-8x-global-styles)
1919
- [Components](#version-8x-components)
2020
- [Button](#version-8x-button)
21+
- [Checkbox](#version-8x-checkbox)
2122
- [Content](#version-8x-content)
2223
- [Datetime](#version-8x-datetime)
2324
- [Input](#version-8x-input)
@@ -140,6 +141,10 @@ For more information on the dynamic font, refer to the [Dynamic Font Scaling doc
140141

141142
- Button text now wraps by default. If this behavior is not desired, add the `ion-text-nowrap` class from the [CSS Utilities](https://ionicframework.com/docs/layout/css-utilities).
142143

144+
<h4 id="version-8x-checkbox">Checkbox</h4>
145+
146+
The `legacy` property and support for the legacy syntax, which involved placing an `ion-checkbox` inside of an `ion-item` with an `ion-label`, have been removed. For more information on migrating from the legacy checkbox syntax, refer to the [Checkbox documentation](https://ionicframework.com/docs/api/checkbox#migrating-from-legacy-checkbox-syntax).
147+
143148
<h4 id="version-8x-content">Content</h4>
144149

145150
- Content no longer sets the `--background` custom property when the `.outer-content` class is set on the host.

core/api.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,6 @@ ion-checkbox,prop,disabled,boolean,false,false,false
297297
ion-checkbox,prop,indeterminate,boolean,false,false,false
298298
ion-checkbox,prop,justify,"end" | "space-between" | "start",'space-between',false,false
299299
ion-checkbox,prop,labelPlacement,"end" | "fixed" | "stacked" | "start",'start',false,false
300-
ion-checkbox,prop,legacy,boolean | undefined,undefined,false,false
301300
ion-checkbox,prop,mode,"ios" | "md",undefined,false,false
302301
ion-checkbox,prop,name,string,this.inputId,false,false
303302
ion-checkbox,prop,value,any,'on',false,false

core/src/components.d.ts

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -630,10 +630,6 @@ export namespace Components {
630630
* Where to place the label relative to the checkbox. `"start"`: The label will appear to the left of the checkbox in LTR and to the right in RTL. `"end"`: The label will appear to the right of the checkbox in LTR and to the left in RTL. `"fixed"`: The label has the same behavior as `"start"` except it also has a fixed width. Long text will be truncated with ellipses ("..."). `"stacked"`: The label will appear above the checkbox regardless of the direction. The alignment of the label can be controlled with the `alignment` property.
631631
*/
632632
"labelPlacement": 'start' | 'end' | 'fixed' | 'stacked';
633-
/**
634-
* Set the `legacy` property to `true` to forcibly use the legacy form control markup. Ionic will only opt checkboxes in to the modern form markup when they are using either the `aria-label` attribute or have text in the default slot. 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.
635-
*/
636-
"legacy"?: boolean;
637633
/**
638634
* The mode determines which platform styles to use.
639635
*/
@@ -3639,7 +3635,6 @@ declare global {
36393635
"ionChange": CheckboxChangeEventDetail;
36403636
"ionFocus": void;
36413637
"ionBlur": void;
3642-
"ionStyle": StyleEventDetail;
36433638
}
36443639
interface HTMLIonCheckboxElement extends Components.IonCheckbox, HTMLStencilElement {
36453640
addEventListener<K extends keyof HTMLIonCheckboxElementEventMap>(type: K, listener: (this: HTMLIonCheckboxElement, ev: IonCheckboxCustomEvent<HTMLIonCheckboxElementEventMap[K]>) => any, options?: boolean | AddEventListenerOptions): void;
@@ -5323,10 +5318,6 @@ declare namespace LocalJSX {
53235318
* Where to place the label relative to the checkbox. `"start"`: The label will appear to the left of the checkbox in LTR and to the right in RTL. `"end"`: The label will appear to the right of the checkbox in LTR and to the left in RTL. `"fixed"`: The label has the same behavior as `"start"` except it also has a fixed width. Long text will be truncated with ellipses ("..."). `"stacked"`: The label will appear above the checkbox regardless of the direction. The alignment of the label can be controlled with the `alignment` property.
53245319
*/
53255320
"labelPlacement"?: 'start' | 'end' | 'fixed' | 'stacked';
5326-
/**
5327-
* Set the `legacy` property to `true` to forcibly use the legacy form control markup. Ionic will only opt checkboxes in to the modern form markup when they are using either the `aria-label` attribute or have text in the default slot. 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.
5328-
*/
5329-
"legacy"?: boolean;
53305321
/**
53315322
* The mode determines which platform styles to use.
53325323
*/
@@ -5347,10 +5338,6 @@ declare namespace LocalJSX {
53475338
* Emitted when the checkbox has focus.
53485339
*/
53495340
"onIonFocus"?: (event: IonCheckboxCustomEvent<void>) => void;
5350-
/**
5351-
* Emitted when the styles change.
5352-
*/
5353-
"onIonStyle"?: (event: IonCheckboxCustomEvent<StyleEventDetail>) => void;
53545341
/**
53555342
* The value of the checkbox does not mean if it's checked or not, use the `checked` property for that. The value of a checkbox is analogous to the value of an `<input type="checkbox">`, it's only used when the checkbox participates in a native `<form>`.
53565343
*/

core/src/components/checkbox/checkbox.ios.scss

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -31,21 +31,3 @@
3131
:host(.checkbox-disabled) {
3232
opacity: $checkbox-ios-disabled-opacity;
3333
}
34-
35-
36-
// iOS Checkbox Within An Item
37-
// TODO(FW-3100): remove this
38-
// -----------------------------------------
39-
40-
:host(.in-item.legacy-checkbox) {
41-
// end position by default
42-
@include margin($checkbox-ios-item-end-margin-top, $checkbox-ios-item-end-margin-end, $checkbox-ios-item-end-margin-bottom, $checkbox-ios-item-end-margin-start);
43-
44-
display: block;
45-
46-
position: static;
47-
}
48-
49-
:host(.in-item.legacy-checkbox[slot="start"]) {
50-
@include margin($checkbox-ios-item-start-margin-top, $checkbox-ios-item-start-margin-end, $checkbox-ios-item-start-margin-bottom, $checkbox-ios-item-start-margin-start);
51-
}

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

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -26,29 +26,5 @@ $checkbox-ios-icon-border-radius: 50% !default;
2626
/// @prop - Opacity of the disabled checkbox
2727
$checkbox-ios-disabled-opacity: $form-control-ios-disabled-opacity !default;
2828

29-
/// @prop - Margin top of the left checkbox item
30-
$checkbox-ios-item-start-margin-top: 8px !default;
31-
32-
/// @prop - Margin end of the left checkbox item
33-
$checkbox-ios-item-start-margin-end: $item-ios-padding-end !default;
34-
35-
/// @prop - Margin bottom of the left checkbox item
36-
$checkbox-ios-item-start-margin-bottom: $checkbox-ios-item-start-margin-top !default;
37-
38-
/// @prop - Margin start of the left checkbox item
39-
$checkbox-ios-item-start-margin-start: 2px !default;
40-
41-
/// @prop - Margin top of the right checkbox item
42-
$checkbox-ios-item-end-margin-top: 10px !default;
43-
44-
/// @prop - Margin end of the right checkbox item
45-
$checkbox-ios-item-end-margin-end: 8px !default;
46-
47-
/// @prop - Margin bottom of the right checkbox item
48-
$checkbox-ios-item-end-margin-bottom: 9px !default;
49-
50-
/// @prop - Margin start of the right checkbox item
51-
$checkbox-ios-item-end-margin-start: 0 !default;
52-
5329
/// @prop - Checkmark width of the checkbox icon
5430
$checkbox-ios-icon-checkmark-width: 1.5px !default;

core/src/components/checkbox/checkbox.md.scss

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -44,29 +44,10 @@
4444
// opacity set by its spec, while the label
4545
// should match the other form controls
4646

47-
:host(.legacy-checkbox.checkbox-disabled),
4847
:host(.checkbox-disabled) .label-text-wrapper {
4948
opacity: $checkbox-md-disabled-opacity;
5049
}
5150

5251
:host(.checkbox-disabled) .native-wrapper {
5352
opacity: $checkbox-md-icon-disabled-opacity;
5453
}
55-
56-
57-
// Material Design Checkbox Within An Item
58-
// TODO(FW-3100): remove this
59-
// --------------------------------------------------------
60-
61-
:host(.in-item.legacy-checkbox) {
62-
// end position by default
63-
@include margin($checkbox-md-item-end-margin-top, $checkbox-md-item-end-margin-end, $checkbox-md-item-end-margin-bottom, $checkbox-md-item-end-margin-start);
64-
65-
display: block;
66-
67-
position: static;
68-
}
69-
70-
:host(.in-item.legacy-checkbox[slot="start"]) {
71-
@include margin($checkbox-md-item-start-margin-top, $checkbox-md-item-start-margin-end, $checkbox-md-item-start-margin-bottom, $checkbox-md-item-start-margin-start);
72-
}

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

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -30,30 +30,6 @@ $checkbox-md-transition-duration: 180ms !default;
3030
/// @prop - Transition easing of the checkbox
3131
$checkbox-md-transition-easing: cubic-bezier(.4, 0, .2, 1) !default;
3232

33-
/// @prop - Margin top of the start checkbox item
34-
$checkbox-md-item-start-margin-top: 18px !default;
35-
36-
/// @prop - Margin end of the start checkbox item
37-
$checkbox-md-item-start-margin-end: 36px !default;
38-
39-
/// @prop - Margin bottom of the start checkbox item
40-
$checkbox-md-item-start-margin-bottom: $checkbox-md-item-start-margin-top !default;
41-
42-
/// @prop - Margin start of the start checkbox item
43-
$checkbox-md-item-start-margin-start: 4px !default;
44-
45-
/// @prop - Margin top of the end checkbox item
46-
$checkbox-md-item-end-margin-top: 18px !default;
47-
48-
/// @prop - Margin end of the end checkbox item
49-
$checkbox-md-item-end-margin-end: 0 !default;
50-
51-
/// @prop - Margin bottom of the end checkbox item
52-
$checkbox-md-item-end-margin-bottom: $checkbox-md-item-end-margin-top !default;
53-
54-
/// @prop - Margin start of the end checkbox item
55-
$checkbox-md-item-end-margin-start: 0 !default;
56-
5733
/// @prop - Opacity of the disabled checkbox
5834
/// This value is used because the checkbox color is set to
5935
/// `rgb(0, 0, 0, 0.60)` when enabled and we need it to be

core/src/components/checkbox/checkbox.scss

Lines changed: 6 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -48,34 +48,17 @@
4848
* toolbar which is why we do not
4949
* limit the below behavior to just ion-item.
5050
*/
51-
:host([slot="start"]:not(.legacy-checkbox)),
52-
:host([slot="end"]:not(.legacy-checkbox)) {
51+
:host([slot="start"]),
52+
:host([slot="end"]) {
5353
width: auto;
5454
}
5555

56-
// TODO(FW-3100): remove this
57-
:host(.legacy-checkbox) {
58-
width: var(--size);
59-
height: var(--size);
60-
}
61-
6256
:host(.ion-color) {
6357
--checkbox-background-checked: #{current-color(base)};
6458
--border-color-checked: #{current-color(base)};
6559
--checkmark-color: #{current-color(contrast)};
6660
}
6761

68-
// TODO(FW-3100): remove this
69-
:host(.legacy-checkbox) label {
70-
@include input-cover();
71-
72-
display: flex;
73-
74-
align-items: center;
75-
76-
opacity: 0;
77-
}
78-
7962
.checkbox-wrapper {
8063
display: flex;
8164

@@ -96,7 +79,7 @@
9679
overflow: hidden;
9780
}
9881

99-
:host(.in-item:not(.legacy-checkbox)) .label-text-wrapper {
82+
:host(.in-item) .label-text-wrapper {
10083
@include margin($checkbox-item-label-margin-top, null, $checkbox-item-label-margin-bottom, null);
10184
}
10285

@@ -132,6 +115,9 @@ input {
132115

133116
position: relative;
134117

118+
width: var(--size);
119+
height: var(--size);
120+
135121
transition: var(--transition);
136122

137123
border-width: var(--border-width);
@@ -143,20 +129,6 @@ input {
143129
box-sizing: border-box;
144130
}
145131

146-
// TODO(FW-3100): remove this
147-
:host(.legacy-checkbox) .checkbox-icon {
148-
display: block;
149-
150-
width: 100%;
151-
height: 100%;
152-
}
153-
154-
// TODO(FW-3100): merge this with other .checkbox-icon styles above
155-
:host(:not(.legacy-checkbox)) .checkbox-icon {
156-
width: var(--size);
157-
height: var(--size);
158-
}
159-
160132
.checkbox-icon path {
161133
fill: none;
162134
stroke: var(--checkmark-color);

0 commit comments

Comments
 (0)