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

clr-tree throws ExpressionChangedAfterItHasBeenCheckedError #1562

Closed
1 of 3 tasks
nkerr opened this issue Sep 21, 2024 · 3 comments
Closed
1 of 3 tasks

clr-tree throws ExpressionChangedAfterItHasBeenCheckedError #1562

nkerr opened this issue Sep 21, 2024 · 3 comments
Assignees

Comments

@nkerr
Copy link

nkerr commented Sep 21, 2024

This is a bug report for the @clr Angular or UI versions of the design system.
For the web-component implementation of Clarity (@cds), visit vmware-clarity/core.

Describe the bug

The clr-tree component throws a ExpressionChangedAfterItHasBeenCheckedError since it binds the aria-multiselectable attribute to isMultiSelectable.

ERROR RuntimeError: NG0100: ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value for 'attr.aria-multiselectable': 'false'. Current value: 'true'. Expression location: ExampleComponent component. Find more at https://angular.io/errors/NG0100
    at throwErrorIfNoChangesMode (vendor.js:50832:9)
    at bindingUpdated (vendor.js:53944:9)
    at ɵɵattribute (vendor.js:53988:7)
    at ClrTree_HostBindings (vendor.js:134676:80)
    at processHostBindingOpCodes (vendor.js:51072:11)
    at refreshView (vendor.js:52687:5)
    at detectChangesInView (vendor.js:52803:5)
    at detectChangesInComponent (vendor.js:52781:3)
    at detectChangesInChildComponents (vendor.js:52815:5)
    at refreshView (vendor.js:52691:7)

How to reproduce

The bug can be easily reproduced by running your recursive tree example in stackblitz:

https://clarity.design/documentation/tree-view/code#recursive-tree

Expected behavior

An exception should not be thrown when running the recursive tree example code.

Versions

Clarity version:

  • v13.x
  • v15.x
  • Other: 17

Framework version:
Angular 16 & 17

Device:

  • Type: Windows PC
  • OS: Windows 10 Pro
  • Browser Chrome
  • Version 128.0.6613.138

Additional notes

Add any other notes about the problem here.

@nkerr
Copy link
Author

nkerr commented Sep 21, 2024

As a workaround for this issue you can invoke the ChangeDetectorRef in ngAterViewInit in your host component:

@Component({
  selector: 'app-my-tree',
  templateUrl: './my-tree.component.html',
  styleUrl: './my-tree.component.scss'
})
export class MyTreeComponent implements AfterViewChecked {
  ...
  ...
  constructor(private cdr: ChangeDetectorRef) {
  }
 
  ngAfterViewChecked(): void {
    this.cdr.detectChanges();
  }
...
}

@valentin-mladenov valentin-mladenov self-assigned this Sep 24, 2024
valentin-mladenov added a commit that referenced this issue Sep 30, 2024
## PR Checklist

Please check if your PR fulfills the following requirements:

- [ ] Tests for the changes have been added (for bug fixes / features)
- [ ] Docs have been added / updated (for bug fixes / features)
- [ ] If applicable, have a visual design approval

## PR Type

What kind of change does this PR introduce?

- [x] Bugfix
- [ ] Feature
- [ ] Code style update (formatting, local variables)
- [ ] Refactoring (no functional changes, no api changes)
- [ ] Build related changes
- [ ] CI related changes
- [ ] Documentation content changes
- [ ] Other... Please describe:

## What is the current behavior?
`clr-tree` throws ExpressionChangedAfterItHasBeenCheckedError when
setting `aria-multiselectable`.

Issue Number: #1562, CDE-2301

## What is the new behavior?
Aria multiselectable attribute is added when needed.

## Does this PR introduce a breaking change?

- [ ] Yes
- [x] No

## Other information
github-actions bot pushed a commit that referenced this issue Sep 30, 2024
## PR Checklist

Please check if your PR fulfills the following requirements:

- [ ] Tests for the changes have been added (for bug fixes / features)
- [ ] Docs have been added / updated (for bug fixes / features)
- [ ] If applicable, have a visual design approval

## PR Type

What kind of change does this PR introduce?

- [x] Bugfix
- [ ] Feature
- [ ] Code style update (formatting, local variables)
- [ ] Refactoring (no functional changes, no api changes)
- [ ] Build related changes
- [ ] CI related changes
- [ ] Documentation content changes
- [ ] Other... Please describe:

## What is the current behavior?
`clr-tree` throws ExpressionChangedAfterItHasBeenCheckedError when
setting `aria-multiselectable`.

Issue Number: #1562, CDE-2301

## What is the new behavior?
Aria multiselectable attribute is added when needed.

## Does this PR introduce a breaking change?

- [ ] Yes
- [x] No

## Other information

(cherry picked from commit 71b0056)
@valentin-mladenov
Copy link
Contributor

The fix will be available with the next v17 release.

valentin-mladenov added a commit that referenced this issue Sep 30, 2024
…ort to 16.x) (#1572)

Backport 71b0056 from #1563. <br> ## PR
Checklist

Please check if your PR fulfills the following requirements:

- [ ] Tests for the changes have been added (for bug fixes / features)
- [ ] Docs have been added / updated (for bug fixes / features)
- [ ] If applicable, have a visual design approval

## PR Type

What kind of change does this PR introduce?

- [x] Bugfix
- [ ] Feature
- [ ] Code style update (formatting, local variables)
- [ ] Refactoring (no functional changes, no api changes)
- [ ] Build related changes
- [ ] CI related changes
- [ ] Documentation content changes
- [ ] Other... Please describe:

## What is the current behavior?
`clr-tree` throws ExpressionChangedAfterItHasBeenCheckedError when
setting `aria-multiselectable`.

Issue Number: #1562, CDE-2301

## What is the new behavior?
Aria multiselectable attribute is added when needed.

## Does this PR introduce a breaking change?

- [ ] Yes
- [x] No

## Other information

Co-authored-by: Valentin Mladenov <[email protected]>
Copy link
Contributor

Hi there 👋, this is an automated message. To help Clarity keep track of discussions, we automatically lock closed issues after 14 days. Please look for another open issue or open a new issue with updated details and reference this one as necessary.

@github-actions github-actions bot locked and limited conversation to collaborators Oct 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants