Skip to content

Commit

Permalink
fix(toggle/checkbox): allow value to be programmatically updated whil…
Browse files Browse the repository at this point in the history
…e disabled

fixes #9730
  • Loading branch information
brandyscarney committed Feb 3, 2017
1 parent 2ed0e12 commit 37c7117
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/components/checkbox/checkbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 3 additions & 0 deletions src/components/checkbox/test/basic/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
16 changes: 16 additions & 0 deletions src/components/checkbox/test/basic/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -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>
2 changes: 1 addition & 1 deletion src/components/toggle/toggle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 37c7117

Please sign in to comment.