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

fix local state 'columns' #2896

Merged

Conversation

graceguo-supercat
Copy link

I found a bug in VisualizeModal:
in setStateFromProps(props), we create a columns object and set into state.
But setStateFromProps will be called every componentWillReceiveProps, which means when user close Modal, open Modal etc, it will reset columns state to original props. For example, if user open modal, changed any checkbox, then close and re-open modal, his previous change will lost. This thing will become more annoying when mixed with redux updating its state.

I think we should keep 'columns' as a local state, and it should remember user's changes even after user close Modal and reopen it. My fix is just calling setStateFromProps from constructor, not from every componentWillReceiveProps.

I found a bug in VisualizeModal:
in setStateFromProps(props), we create columns object and set into state.
But setStateFromProps will be called every componentWillReceiveProps, which means when user close Modal, open Modal etc, it will reset columns state to original props. As a result if user changed any checkbox, then close and re-open modal, his previous change will lost. This thing will become more annoying when mixed with redux updating its state.

I think we should keep 'columns' as a local state, and it should remember states even after user close Modal and reopen it. my fix is just calling setStateFromProps from constructor, not from every componentWillReceiveProps.
Copy link
Member

@mistercrunch mistercrunch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor semantic issue to fix, otherwise LGTM

this.setStateFromProps(nextProps);
}
setStateFromProps(props) {
setStateFromProps() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably need to change the function name now that it does not setState anymore. getColumnFromProps?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed method name.

@graceguo-supercat graceguo-supercat merged commit 1dcf2c4 into apache:master Jun 15, 2017
@graceguo-supercat graceguo-supercat deleted the gg-keepColumnsStateLocal branch June 15, 2017 22:30
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 0.18.5 labels Feb 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 0.18.5
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants