rreganjr / chichi-ng

component library for angular
MIT License
0 stars 0 forks source link

[Bug]: ExpressionChangedAfterItHasBeenCheckedError in channel #39

Closed rreganjr closed 2 years ago

rreganjr commented 2 years ago

Chichi-ng Version

not listed

Angular Version

13.3.1

Description

In the demo event-schedular I moved adding agenda items into ngAfterViewInit so the start/end date have propogated through the scheduler component to the scheduler service and can be used to validate the addAgendaItem() dates in the correct bounds,

Now the channel component gets ExpressionChangedAfterItHasBeenCheckedError because the visibleAgendaItems$ changes

core.mjs:6485 ERROR Error: NG0100: ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value: 'null'. Current value: '[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]'.. Find more at https://angular.io/errors/NG0100
    at throwErrorIfNoChangesMode (core.mjs:6733:1)
    at bindingUpdated (core.mjs:12710:1)
    at Module.ɵɵproperty (core.mjs:14443:1)
    at ChannelComponent_Template (channel.component.html:1:74)

Expected Behavior

it works

Actual Behavior

it not works

rreganjr commented 2 years ago

fixed in branch issue-39

I fixed issue 39 in the channel component by using debounceTime(50) instead of a delay or setTimeout as it adds the benefit of minimizing re-rendering after each agendaItem is added if initialization happens in ngAfterViewInit() of the event-scheduler (demo) instead of ngOnInit(). In ResourceChannelMapData I changed the subject to use a BehaviorSubject instead of ReplaySubject so that if there isn't any initial agendaItems the channels still initialize to one big drop-zone. In agend-item component I stopPropagation on delete click so that it doesn't open the editor for the item just deleted, which was the click passing to the agend-item.