Skip to content

bSwitch gets focused even when it's disabled  #34

@ahadjithoma

Description

@ahadjithoma

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions