Skip to content

Commit f94bcad

Browse files
Merge branch 'ROU-11112-checkbox' into ROU-11112
2 parents 2dd8a18 + 0a502a1 commit f94bcad

File tree

4 files changed

+36
-8
lines changed

4 files changed

+36
-8
lines changed

core/src/components.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,7 @@ export namespace Components {
644644
*/
645645
"name": string;
646646
/**
647-
* If `true`, the user must fill in a value before submitting a form.
647+
* If true, screen readers will announce it as a required field. This property works only for accessibility purposes, it will not prevent the form from submitting if the value is invalid.
648648
*/
649649
"required": boolean;
650650
"setFocus": () => Promise<void>;
@@ -5452,7 +5452,7 @@ declare namespace LocalJSX {
54525452
*/
54535453
"onIonFocus"?: (event: IonCheckboxCustomEvent<void>) => void;
54545454
/**
5455-
* If `true`, the user must fill in a value before submitting a form.
5455+
* If true, screen readers will announce it as a required field. This property works only for accessibility purposes, it will not prevent the form from submitting if the value is invalid.
54565456
*/
54575457
"required"?: boolean;
54585458
/**

core/src/components/checkbox/checkbox.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,9 @@ export class Checkbox implements ComponentInterface {
9999
@Prop() alignment?: 'start' | 'center';
100100

101101
/**
102-
* If `true`, the user must fill in a value before submitting a form.
102+
* If true, screen readers will announce it as a required field. This property
103+
* works only for accessibility purposes, it will not prevent the form from
104+
* submitting if the value is invalid.
103105
*/
104106
@Prop() required = false;
105107

@@ -187,7 +189,7 @@ export class Checkbox implements ComponentInterface {
187189
name,
188190
value,
189191
alignment,
190-
required
192+
required,
191193
} = this;
192194
const mode = getIonMode(this);
193195
const path = getSVGPath(mode, indeterminate);

core/src/components/checkbox/test/checkbox.spec.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,33 @@ describe('ion-checkbox: indeterminate', () => {
5454
expect(checkbox.getAttribute('aria-checked')).toBe('mixed');
5555
});
5656
});
57+
58+
describe('ion-checkbox: required', () => {
59+
it('should have a required attribute in inner input when true', async () => {
60+
const page = await newSpecPage({
61+
components: [Checkbox],
62+
html: `
63+
<ion-checkbox required="true">Checkbox</ion-checkbox>
64+
`,
65+
});
66+
67+
const checkbox = page.body.querySelector('ion-checkbox')!;
68+
const nativeInput = checkbox.shadowRoot?.querySelector('input[type=checkbox]')!;
69+
70+
expect(nativeInput.hasAttribute('required')).toBeTruthy();
71+
});
72+
73+
it('should not have a required attribute in inner input when false', async () => {
74+
const page = await newSpecPage({
75+
components: [Checkbox],
76+
html: `
77+
<ion-checkbox required="false">Checkbox</ion-checkbox>
78+
`,
79+
});
80+
81+
const checkbox = page.body.querySelector('ion-checkbox')!;
82+
const nativeInput = checkbox.shadowRoot?.querySelector('input[type=checkbox]')!;
83+
84+
expect(nativeInput.hasAttribute('required')).toBeFalsy();
85+
});
86+
});

packages/vue/src/proxies.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -243,10 +243,6 @@ export const IonCheckbox = /*@__PURE__*/ defineContainer<JSX.IonCheckbox, JSX.Io
243243
'ionChange',
244244
'ionFocus',
245245
'ionBlur'
246-
], [
247-
'ionChange',
248-
'ionFocus',
249-
'ionBlur'
250246
],
251247
'checked', 'ion-change');
252248

0 commit comments

Comments
 (0)