survey-library icon indicating copy to clipboard operation
survey-library copied to clipboard

Recently required to call this.changeDetectorRef.detectChanges(); inside of onComplete()

Open jdearing-neudesic opened this issue 2 years ago • 0 comments

Are you requesting a feature, reporting a bug or asking a question?

bug

What is the current behavior?

when onComplete() sets a bool from true to false to hide and show ng-containers it does not fire detectChanges() and the changes do not take effect. This is a new, and I can only tie it to recent upgrades to survey-angular. I was on ng 13.1 when it stated happening and upgaded to the latest version which did not resolve it.

I even tried wrapping the boolean in BehaviorSubject. I verified with console.log() that ngInit doesnt even fire on the component inside the container

What is the expected behavior?

To not need this.changeDetectorRef.detectChanges();

How would you reproduce the current behavior (if this is a bug)?

Working on ful suscint example but basically an onComplete event that looks like this

          surveyModel.onComplete.add((result: SurveyModel, options: any) => {
          console.debug(`Survey ${this.surveyName} completed.`);
          
          this.submisionSub = this.surveyService.submitAnswers(this.surveyName, result)
            .subscribe({
              next: submissionResults => {
                console.debug('Submission results received.');
                this.hasSurveyComplete.next(true);
                // this.changeDetectorRef.detectChanges();
              },
              error: err => {
                console.error('Error recieving submission results.');
                this.hasSurveyComplete.next(true);  
                // this.changeDetectorRef.detectChanges();
              }
            });
            // this.changeDetectorRef.detectChanges();
        });

and then an component that looks like this

<app-completed *ngIf="(hasSurveyComplete | async) === false"></app-completed> inside the component with the survey.

Specify your

  • browser: edge
  • browser version: latest
  • surveyjs platform angular 1.9.32
  • surveyjs version: 1.9.7

jdearing-neudesic avatar May 26 '22 15:05 jdearing-neudesic