mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-16 10:01:59 +08:00
Merge branch 'ROU-11112-checkbox' into ROU-11112
This commit is contained in:
4
core/src/components.d.ts
vendored
4
core/src/components.d.ts
vendored
@ -644,7 +644,7 @@ export namespace Components {
|
|||||||
*/
|
*/
|
||||||
"name": string;
|
"name": string;
|
||||||
/**
|
/**
|
||||||
* If `true`, the user must fill in a value before submitting a form.
|
* 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.
|
||||||
*/
|
*/
|
||||||
"required": boolean;
|
"required": boolean;
|
||||||
"setFocus": () => Promise<void>;
|
"setFocus": () => Promise<void>;
|
||||||
@ -5452,7 +5452,7 @@ declare namespace LocalJSX {
|
|||||||
*/
|
*/
|
||||||
"onIonFocus"?: (event: IonCheckboxCustomEvent<void>) => void;
|
"onIonFocus"?: (event: IonCheckboxCustomEvent<void>) => void;
|
||||||
/**
|
/**
|
||||||
* If `true`, the user must fill in a value before submitting a form.
|
* 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.
|
||||||
*/
|
*/
|
||||||
"required"?: boolean;
|
"required"?: boolean;
|
||||||
/**
|
/**
|
||||||
|
@ -99,7 +99,9 @@ export class Checkbox implements ComponentInterface {
|
|||||||
@Prop() alignment?: 'start' | 'center';
|
@Prop() alignment?: 'start' | 'center';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If `true`, the user must fill in a value before submitting a form.
|
* 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.
|
||||||
*/
|
*/
|
||||||
@Prop() required = false;
|
@Prop() required = false;
|
||||||
|
|
||||||
@ -187,7 +189,7 @@ export class Checkbox implements ComponentInterface {
|
|||||||
name,
|
name,
|
||||||
value,
|
value,
|
||||||
alignment,
|
alignment,
|
||||||
required
|
required,
|
||||||
} = this;
|
} = this;
|
||||||
const mode = getIonMode(this);
|
const mode = getIonMode(this);
|
||||||
const path = getSVGPath(mode, indeterminate);
|
const path = getSVGPath(mode, indeterminate);
|
||||||
|
@ -54,3 +54,33 @@ describe('ion-checkbox: indeterminate', () => {
|
|||||||
expect(checkbox.getAttribute('aria-checked')).toBe('mixed');
|
expect(checkbox.getAttribute('aria-checked')).toBe('mixed');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('ion-checkbox: required', () => {
|
||||||
|
it('should have a required attribute in inner input when true', async () => {
|
||||||
|
const page = await newSpecPage({
|
||||||
|
components: [Checkbox],
|
||||||
|
html: `
|
||||||
|
<ion-checkbox required="true">Checkbox</ion-checkbox>
|
||||||
|
`,
|
||||||
|
});
|
||||||
|
|
||||||
|
const checkbox = page.body.querySelector('ion-checkbox')!;
|
||||||
|
const nativeInput = checkbox.shadowRoot?.querySelector('input[type=checkbox]')!;
|
||||||
|
|
||||||
|
expect(nativeInput.hasAttribute('required')).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should not have a required attribute in inner input when false', async () => {
|
||||||
|
const page = await newSpecPage({
|
||||||
|
components: [Checkbox],
|
||||||
|
html: `
|
||||||
|
<ion-checkbox required="false">Checkbox</ion-checkbox>
|
||||||
|
`,
|
||||||
|
});
|
||||||
|
|
||||||
|
const checkbox = page.body.querySelector('ion-checkbox')!;
|
||||||
|
const nativeInput = checkbox.shadowRoot?.querySelector('input[type=checkbox]')!;
|
||||||
|
|
||||||
|
expect(nativeInput.hasAttribute('required')).toBeFalsy();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
@ -243,10 +243,6 @@ export const IonCheckbox = /*@__PURE__*/ defineContainer<JSX.IonCheckbox, JSX.Io
|
|||||||
'ionChange',
|
'ionChange',
|
||||||
'ionFocus',
|
'ionFocus',
|
||||||
'ionBlur'
|
'ionBlur'
|
||||||
], [
|
|
||||||
'ionChange',
|
|
||||||
'ionFocus',
|
|
||||||
'ionBlur'
|
|
||||||
],
|
],
|
||||||
'checked', 'ion-change');
|
'checked', 'ion-change');
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user