JulioWar / jw-bootstrap-switch-ng2

Bootstrap Switch for Angular 2+
https://juliowar.github.io/jw-bootstrap-switch-ng2/
MIT License
43 stars 14 forks source link

bSwitch gets focused even when it's disabled #34

Open ahadjithoma opened 4 years ago

ahadjithoma commented 4 years ago

Bug Report or Feature Request (mark with an x)

- [X] bug report -> please search issues before submitting
- [ ] feature request

Versions.

Angular: 8.24 bSwitch: 2.0.5

Repro steps.

https://stackblitz.com/edit/angular-ybggsn?embed=1&file=app/modal-component.ts

The log given by the failure.

Error: ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value: 'ngClass: bootstrap-switch bootstrap-switch-wrapper bootstrap-switch-small bootstrap-switch-off bootstrap-switch-disabled bootstrap-switch-indeterminate'. Current value: 'ngClass: bootstrap-switch bootstrap-switch-wrapper bootstrap-switch-focused bootstrap-switch-small bootstrap-switch-off bootstrap-switch-disabled bootstrap-switch-indeterminate'.

Desired functionality.

The problem occurs when the bSwitch is used inside an NgbModal. By design, the ngbModal tries to set focus to the first not disabled input available. When we use a disabled bSwitch it gets focused by the modal, thus the error in console.

When the bSwitch is disabled it shouldn't get focused.

Mention any other details that might be useful.

JulioWar commented 4 years ago

@andreash92 I will check that scenario. Thanks for your feedback