surveyjs / custom-widgets

The collection of custom widgets for SurveyJS: Survey Library and Survey Creator :package:
https://surveyjs.io
MIT License
79 stars 77 forks source link

Uncaught TypeError: Cannot read property 'remove' of undefined (with visibleIf) #78

Closed akrapacs closed 6 years ago

akrapacs commented 6 years ago

I'm encountering this error frequently in my React/SurveyJS app but this is the first scenario where I was able to reproduce it with a simple test. I have a "visibleif" condition on a field based on a yes/no answer. Initially the conditional field is hidden. When I click "Yes" on the parent field the hidden field showsand when I click no the runtime error occurs. It is easily reproduced in the surveyjs_react_quickstart with the sample survey below.

Relevant package.json packages:

    "@babel/runtime": "^7.0.0-beta.42",
    "axios": "^0.18.0",
    "bootstrap": "^3.3.7",
    "bootstrap-slider": "^10.2.0",
    "icheck": "^1.0.2",
    "jquery": "^3.3.1",
    "jquery-bar-rating": "^1.2.2",
    "jquery-ui": "^1.12.1",
    "nouislider": "^11.1.0",
    "react": "^16.4.2",
    "react-bootstrap": "^0.32.2",
    "react-dom": "^16.4.2",
    "react-modal": "^3.5.1",
    "react-scripts": "1.1.4",
    "select2": "^4.0.6-rc.1",
    "survey-react": "^1.0.41",
    "surveyjs-editor": "^1.0.41",
    "surveyjs-widgets": "^1.0.41"

The error(s):

surveyjs-widgets.js:541 Uncaught TypeError: Cannot read property 'remove' of undefined
    at Object.willUnmount (surveyjs-widgets.js:541)
    at QuestionCustomWidget.willUnmount (survey.react.js:14684)
    at SurveyCustomWidget.componentWillUnmount (survey.react.js:23655)
    at callComponentWillUnmountWithTimer (react-dom.development.js:14280)
    at HTMLUnknownElement.callCallback (react-dom.development.js:100)
    at Object.invokeGuardedCallbackDev (react-dom.development.js:138)
    at invokeGuardedCallback (react-dom.development.js:187)
    at safelyCallComponentWillUnmount (react-dom.development.js:14287)
    at commitUnmount (react-dom.development.js:14494)
    at commitNestedUnmounts (react-dom.development.js:14525)
    at unmountHostComponents (react-dom.development.js:14776)
    at commitDeletion (react-dom.development.js:14827)
    at commitAllHostEffects (react-dom.development.js:15416)
    at HTMLUnknownElement.callCallback (react-dom.development.js:100)
    at Object.invokeGuardedCallbackDev (react-dom.development.js:138)
    at invokeGuardedCallback (react-dom.development.js:187)
    at commitRoot (react-dom.development.js:15568)
    at completeRoot (react-dom.development.js:16618)
    at performWorkOnRoot (react-dom.development.js:16563)
    at performWork (react-dom.development.js:16482)
    at flushInteractiveUpdates$1 (react-dom.development.js:16727)
    at batchedUpdates (react-dom.development.js:2143)
    at dispatchEvent (react-dom.development.js:4555)
    at interactiveUpdates$1 (react-dom.development.js:16714)
    at interactiveUpdates (react-dom.development.js:2150)
    at dispatchInteractiveEvent (react-dom.development.js:4532)
willUnmount @ surveyjs-widgets.js:541
QuestionCustomWidget.willUnmount @ survey.react.js:14684
SurveyCustomWidget.componentWillUnmount @ survey.react.js:23655
callComponentWillUnmountWithTimer @ react-dom.development.js:14280
callCallback @ react-dom.development.js:100
invokeGuardedCallbackDev @ react-dom.development.js:138
invokeGuardedCallback @ react-dom.development.js:187
safelyCallComponentWillUnmount @ react-dom.development.js:14287
commitUnmount @ react-dom.development.js:14494
commitNestedUnmounts @ react-dom.development.js:14525
unmountHostComponents @ react-dom.development.js:14776
commitDeletion @ react-dom.development.js:14827
commitAllHostEffects @ react-dom.development.js:15416
callCallback @ react-dom.development.js:100
invokeGuardedCallbackDev @ react-dom.development.js:138
invokeGuardedCallback @ react-dom.development.js:187
commitRoot @ react-dom.development.js:15568
completeRoot @ react-dom.development.js:16618
performWorkOnRoot @ react-dom.development.js:16563
performWork @ react-dom.development.js:16482
flushInteractiveUpdates$1 @ react-dom.development.js:16727
batchedUpdates @ react-dom.development.js:2143
dispatchEvent @ react-dom.development.js:4555
interactiveUpdates$1 @ react-dom.development.js:16714
interactiveUpdates @ react-dom.development.js:2150
dispatchInteractiveEvent @ react-dom.development.js:4532
index.js:2178 The above error occurred in the <SurveyCustomWidget> component:
    in SurveyCustomWidget (created by SurveyQuestion)
    in div (created by SurveyQuestion)
    in div (created by SurveyQuestion)
    in SurveyQuestion (created by SurveyRow)
    in div (created by SurveyRow)
    in SurveyRow (created by SurveyPage)
    in div (created by SurveyPage)
    in SurveyPage (created by Survey)
    in div (created by Survey)
    in div (created by Survey)
    in div (created by Survey)
    in Survey (at App.js:65)
    in div (at App.js:62)
    in div (at App.js:57)
    in App (at index.js:7)

The sample survey I'm using: {"pages":[{"name":"page1","elements":[{"type":"radiogroup","name":"want_to_see","title":"Do you want to see the field below?","choices":[{"value":"yes","text":"Yes"},{"value":"no","text":"No"}]},{"type":"multipletext","name":"the_field","visibleIf":"{want_to_see} = \"yes\"","title":"This is a multiple text element","items":[{"name":"text1","title":"Text 1:"},{"name":"text2","title":"Text 2:"}]}]}]}

andrewtelnov commented 6 years ago

@akrapacs I believe I have fixed the bug with my commit.

Thank you, Andrew

akrapacs commented 6 years ago

Confirmed fixed after updating to 1.0.42