surveyjs / survey-library

Free JavaScript form builder library with integration for React, Angular, Vue, jQuery, and Knockout.
https://surveyjs.io/form-library
MIT License
4.18k stars 808 forks source link

Clicking 'Next' button does not go to next page #1437

Closed ekim-novus closed 5 years ago

ekim-novus commented 5 years ago

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

Reporting a bug

What is the current behavior?

After updating to package v1.0.54, clicking the "Next" button does not go to the next page (also happening in 1.0.55).

What is the expected behavior?

Clicking the "Next" button should bring the survey to the next page.

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

This one's a doozy.... I'm not sure how to repro this, and I don't see the issue happening when I locally build the example react survey after replacing the sample JSON with my own (seen below)... so I am really hoping the little info I found from investigating will be enough to guess what the issue might be:

  1. When I git pulled the project, I built the package at various commits to use locally in my project, and found the commit that broke the Next button: https://github.com/surveyjs/surveyjs/commit/67fe99f151d2a2608e70b9101d10cbf401534afa (so in this commit and onwards, the "Next" button doesn't work for me)

  2. When debugging inside handleNextClick (the click event handler for the "Next" button) in reactSurveyNavigation.tsx:

    • The first time I click the button, this.survey.nextPage() returns true
    • The 2nd time I click, this.survey.nextPage() returns false from this line: if (this.isEditMode && this.isCurrentPageHasErrors) return false because the survey thinks the question has a AnswerRequiredError (even though the input is valid)

I apologize for the lack of info, but thought I'd try to see if someone else can figure out what might be happening.

Provide the test code and the tested page URL (if applicable)

Test JSON

{
    "pages": [{
            "name": "page1",
            "elements": [{
                "type": "text",
                "name": "question1",
                "title": "How old are you?",
                "isRequired": true,
                "validators": [{
                    "type": "numeric",
                    "minValue": 18,
                    "maxValue": 99
                }],
                "placeHolder": "(years)"
            }]
        },
        {
            "name": "page2",
            "elements": [{
                "type": "radiogroup",
                "name": "question2",
                "title": "What is your sex?",
                "isRequired": true,
                "choices": [{
                        "value": "M",
                        "text": "Male"
                    },
                    {
                        "value": "F",
                        "text": "Female"
                    }
                ]
            }]
        }
    ]
}

Specify your

dmitry-kurmanov commented 5 years ago

Hello!

I'm not sure how to repro this, and I don't see the issue happening

yes, here the plunker and it looks ok https://plnkr.co/edit/GfTgCmgmfT0X4tDb9kPf?p=preview

We are working on impoving surveyjs react version updating. Please look at: https://github.com/surveyjs/surveyjs/issues/1432

So I think that it make sense to try the latest build (https://github.com/surveyjs/surveyjs/commit/87172bbd3cf67fa773f3484c65eba4ac3183ba22) may be it will help.

Also it would be greate if you can share with us the repo with the bug. And we will check it.

Thanks.

ekim-novus commented 5 years ago

Hi @dmitrykurmanov ! Sorry I'm not able to provide the repo since it is private.

The latest build did not fix the Next button issue for me either, so I guess I shall continue investigating.

lucasharada commented 5 years ago

Having the same problem with survey-react: 1.0.55. But works perfectly on version1.0.53.

tsv2013 commented 5 years ago

@dmitrykurmanov Have prepared a sample - https://plnkr.co/edit/GfTgCmgmfT0X4tDb9kPf?p=preview In the sample he's using v1.0.55. And it works ok for me - survey goes to the next page and back ok. @ekim-novus @lucasharada Can you check this plunk - whether it works for you?

lucasharada commented 5 years ago

@tsv2013 The plunk works perfectly for me. Not sure the effects that it has, but I'm also using some packages with HOC, such as material-ui, redux and redux-saga.

Also, the React quickstart example runs fine, but didn't work when trying to implement in my own project.

ekim-novus commented 5 years ago

Another thing I noticed is that when I click the Next button for the first time, the survey.currentPage and survey.currentPageNo values do change to the next page, but the page itself doesn't render.

I am also using redux & redux-saga if that means anything.

ekim-novus commented 5 years ago

I found some new info after debugging the below commit (which is the one that I mentioned broke the Next button for me): https://github.com/surveyjs/surveyjs/commit/67fe99f151d2a2608e70b9101d10cbf401534afa

In the file 'reactSurvey.tsx', this.survey.setPropertyValueCoreHandler and this.survey.iteratePropertiesHash were moved out of the updateSurvey() function to somewhere else. Because of this, setPropertyValueCoreHandler is never called for some reason, in my local project.

When I revert this change in that commit (ie. placing those lines back into updateSurvey()), the Next button works again. setPropertyValueCoreHandler is called when clicking the Next button.

Additionally, in the latest commit: https://github.com/surveyjs/surveyjs/commit/bd731efe960c77cb99befdfcf1f647b2af700f5a setPropertyValueCoreHandler in the file 'reactquestionelement.tsx,' is also never called when clicking the Next button, in my local project.

When I test the plunker posted above ^ , however, setPropertyValueCoreHandler is being called.

I still don't really have a good understanding of the problem, and I am still quite a beginner at React, but I think there's something about the way React states are managed that are not registering the setPropertyValueCoreHandler?

nwvaras commented 5 years ago

I have the same problem, using material-ui.

nwvaras commented 5 years ago

Having the same problem with survey-react: 1.0.55. But works perfectly on version1.0.53.

Same here. Using also material-ui, and redux

dmitry-kurmanov commented 5 years ago

We've reproduced and fixed the issue. Fix will be available in the next minor update.

andrewtelnov commented 5 years ago

@nwvaras @ekim-novus @lucasharada We have released new minor version. Please try it out.

Thank you, Andrew

ekim-novus commented 5 years ago

@dmitrykobets @nwvaras The new version 1.0.56 works, thank you!