Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CheckboxInputOptions stores values from all checkbox questions #45

Closed
zvibogen opened this issue Nov 2, 2015 · 6 comments
Closed

CheckboxInputOptions stores values from all checkbox questions #45

zvibogen opened this issue Nov 2, 2015 · 6 comments

Comments

@zvibogen
Copy link

zvibogen commented Nov 2, 2015

I am having an issue that when I have numerous questions that use the input type checkboxOptionsInput the checked answers are added the state including one from previous questions, thereby causing the answer to include all checked boxes from all of the different questions that use an checkboxOptionsInput.
I think it might be due to the fact that the constructor set the state to the props.value and when the state is updated it also resets the props.value.

@andrewhathaway
Copy link
Owner

Do any of your question IDs match across your config? If this is the case, it will cause issues.

@xjlu
Copy link

xjlu commented Jul 15, 2016

I can confirm this issue. Essentially, all selected values from the panel 1 are carried over to the next multi choice panel. And, even if I uncheck a value in the panel 1, the value is still carried over to the next panel.

An Example would be, Panel 1 has only one question Q1 with [a, b, c, d], and Panel 2 has only one question Q2 with [e, f, g, h, i, g]. Click a, b, c, then uncheck c. Q2 has [a, b]. After switching to Panel 2, click e, g. Now Q2 has [a, b, c, e, g]. And sometimes, Q1 will have all Q2's choices, too.

@zvibogen
Copy link
Author

I ended up finding a solution to my issue.
If you adjust the file Winterfell/dist/inputTypes/checkboxOptionsInput.js Line 22 from :
value: this.props.value
To:
value: this.props.value.length > 0 ? this.props.value.slice(0) : [];
it should solve this issue.
I have to admit it was a little while back and I don't remember if that was the only change I needed to get it to work but I am pretty sure it was all that was needed.

@xjlu
Copy link

xjlu commented Jul 19, 2016

Thanks a lot. I was looking at the same line, too. Your changes did fix it by cloning the array so that it won't change the original props.value array. It's not a problem with other types of input because others are not objects.

@andrewhathaway
Copy link
Owner

Appreciate finding the issue and yes, the clone is what will fix this. I'll have to find some time to work in a fix, or maybe this can be pull requested. :)

@andrewhathaway
Copy link
Owner

Fixed in latest version (coming today).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants