jw-bootstrap-switch-ng2
jw-bootstrap-switch-ng2 copied to clipboard
bSwitch gets focused even when it's disabled
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.
@andreash92 I will check that scenario. Thanks for your feedback