mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-20 20:33:32 +08:00
fix(toggle/checkbox): allow value to be programmatically updated while disabled (#10304)
fixes #9730
This commit is contained in:

committed by
Justin Willis

parent
305cc623a7
commit
b8ee3018b5
@ -158,7 +158,7 @@ export class Checkbox extends Ion implements IonicTapInput, AfterContentInit, Co
|
||||
* @private
|
||||
*/
|
||||
_setChecked(isChecked: boolean) {
|
||||
if (!this._disabled && isChecked !== this._checked) {
|
||||
if (isChecked !== this._checked) {
|
||||
this._checked = isChecked;
|
||||
if (this._init) {
|
||||
this.ionChange.emit(this);
|
||||
|
@ -27,6 +27,9 @@ export class E2EPage {
|
||||
'grape': this.grapeCtrl
|
||||
});
|
||||
|
||||
public checked: boolean = false;
|
||||
public disabled: boolean = false;
|
||||
|
||||
constructor() {
|
||||
this.grapeChecked = true;
|
||||
this.standAloneChecked = true;
|
||||
|
@ -88,4 +88,20 @@
|
||||
|
||||
<pre aria-hidden="true" padding>{{formResults}}</pre>
|
||||
|
||||
<ion-item>
|
||||
<ion-label>Checkbox / Toggle</ion-label>
|
||||
<ion-checkbox [(ngModel)]="checked" [disabled]="disabled"></ion-checkbox>
|
||||
<ion-toggle [(ngModel)]="checked" [disabled]="disabled"></ion-toggle>
|
||||
</ion-item>
|
||||
<ion-item>
|
||||
<ion-label>checked</ion-label>
|
||||
<ion-checkbox [(ngModel)]="checked"></ion-checkbox>
|
||||
<ion-toggle [(ngModel)]="checked"></ion-toggle>
|
||||
</ion-item>
|
||||
<ion-item>
|
||||
<ion-label>disabled</ion-label>
|
||||
<ion-checkbox [(ngModel)]="disabled"></ion-checkbox>
|
||||
<ion-toggle [(ngModel)]="disabled"></ion-toggle>
|
||||
</ion-item>
|
||||
|
||||
</ion-content>
|
||||
|
@ -229,7 +229,7 @@ export class Toggle extends Ion implements IonicTapInput, AfterContentInit, Cont
|
||||
* @private
|
||||
*/
|
||||
_setChecked(isChecked: boolean) {
|
||||
if (!this._disabled && isChecked !== this._checked) {
|
||||
if (isChecked !== this._checked) {
|
||||
this._checked = isChecked;
|
||||
if (this._init) {
|
||||
this.ionChange.emit(this);
|
||||
|
Reference in New Issue
Block a user