surveyjs / surveyjs_angular_cli

SurveyJS + Angular CLI Quickstart Template
http://surveyjs.io/
40 stars 52 forks source link

Survey not able to rerender after Survey Creator has rendered #23

Closed keaj-albert closed 5 years ago

keaj-albert commented 5 years ago

I have a parent component that has two child components. A survey component and a survey-creator component. The parent component has a button to toggle whether the survey component is visible or the survey-creator component is visible (via ngIf).

The problem is that after viewing the survey-creator component and toggling back to the survey component, the survey component doesn't render.

Steps to reproduce with this simple project:

  1. Run ng serve to open application at localhost:4200. Survey component should be visible.
  2. Click the button that says "true". Survey-creator component should now be visible.
  3. Click the button that now says "false". Notice that the survey component does not render.
tsv2013 commented 5 years ago

@dmitrykurmanov Could you take a look?

dmitry-kurmanov commented 5 years ago

@tsv2013 I think we have some problem with the knockout templates reusing.

@keaj-albert I've prepared a workaround for you, please check this code:

    ...

    console.log("init survey");

    function surveyFix() {
      var surveyContentParentNode = null;
      var surveyContentNode = document.getElementById("survey-content");
      var isRenderedBefore = !!surveyContentNode;

      if (isRenderedBefore) {
        surveyContentParentNode = surveyContentNode.parentNode;
        surveyContentParentNode.parentNode.removeChild(surveyContentParentNode);
      }
    }
    surveyFix();

    surveyModel.render("surveyElement");

and I created a PR https://github.com/albertjke/surveyjs-poc/pull/1

keaj-albert commented 5 years ago

@dmitrykurmanov Thanks for taking a look! Workaround is working.

dmitry-kurmanov commented 5 years ago

the problem appears in ko 3.5.0 (3.4.0 works fine)

keaj-albert commented 5 years ago

@dmitrykurmanov Using ko 3.4.0 now and it works as expected. Thanks!

tsv2013 commented 5 years ago

We've fixed the issue. Fix will be available in the nearest update, most likely next tuesday.

tsv2013 commented 5 years ago

We've fixed the issue. Fix will be available in the nearest update, most likely next tuesday.