Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot programmatically change disabled ion-checkbox or ion-toggle #9730

Closed
ghost opened this issue Dec 20, 2016 · 7 comments · Fixed by #10304
Closed

Cannot programmatically change disabled ion-checkbox or ion-toggle #9730

ghost opened this issue Dec 20, 2016 · 7 comments · Fixed by #10304
Assignees
Milestone

Comments

@ghost
Copy link

ghost commented Dec 20, 2016

Ionic version:

[ ] 1.x
[x] 2.x

I'm submitting a ...

[x] bug report
[ ] feature request
[ ] support request

Current behavior:

The visible checked state of a disabled ion-checkbox or ion-toggle cannot be changed programmatically.

Expected behavior:

Although clicking a disabled ion-checkbox or ion-toggle obviously should have no effect, I expect to be able to change the checked state programmatically.

Steps to reproduce:

  • Open http://plnkr.co/edit/SAaWEqIvbhX3vzCtT3xG?p=preview
  • Click “checked” multiple times → “Checkbox / Toggle” changes as expected
  • Click “disabled” once
  • Click “checked” multiple times → “Checkbox / Toggle” does not change but I expect it to change

Other information:

Programmatically changing the text of a disabled ion-input works as expected: http://plnkr.co/edit/ZTPqKlzodr5HECR3z6MN?p=preview

Ionic info:

Cordova CLI: 6.4.0
Ionic Framework Version: 2.0.0-rc.4
Ionic CLI Version: 2.1.17
Ionic App Lib Version: 2.1.7
Ionic App Scripts Version: 0.0.47
ios-deploy version: Not installed
ios-sim version: Not installed
OS: Linux 3.13
Node Version: v6.9.2
Xcode version: Not installed

@jgw96 jgw96 added the v2 label Dec 21, 2016
@brandyscarney brandyscarney self-assigned this Jan 12, 2017
@naomipol
Copy link

naomipol commented Jan 30, 2017

Using ngModel with a disabled toggle doesn't work as well:

<ion-toggle
    [(ngModel)]="checked"
    [disabled]="true">
</ion-toggle>

Changes in the model do not effect the disabled toggle
This should be solved!

@jamesgroat
Copy link
Contributor

@brandyscarney

I'm running into this as well. Seems like disabled should only stop propagation of the click events and not the checked setter or writevalue function.

Perhaps like this: jamesgroat@4cf92e9

(not actually tested and it is possible my commit misses some other side effect ...)

@brandyscarney
Copy link
Member

Yeah, it should just be removing !this._disabled && from the _setCheck for both toggle and checkbox since the item, checkbox and toggle being disabled will prevent pointer events and the click won't trigger. I can submit a PR for this unless you'd like to. :)

@jamesgroat
Copy link
Contributor

Please ago ahead -- I don't feel like I'm setup enough to correctly test changes.

@brandyscarney
Copy link
Member

This will be in the next release. I released a nightly with this fix in it, could you please try it out and let me know if you notice any problems?

npm install --save --save-exact [email protected]

Thanks! :)

@ghost
Copy link
Author

ghost commented Feb 6, 2017

@brandyscarney: I tested my project with [email protected]: Bug is fixed, no other problems found, thank you!

@ionitron-bot
Copy link

ionitron-bot bot commented Sep 4, 2018

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Sep 4, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants