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
fixing dashboard state filters #20480
Conversation
Can we add a test for this one? :) |
hard, as nothing fails at the moment, but it will once we remove angular from visualize ... so maybe we add test then ? |
💚 Build Succeeded |
actually the test is already there, but is at the moment passing even if the behaviour is wrong. however with #20295 the test is failing unless this fix is applied |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the cloneDeep should go into the updateFilters function, rather than being the responsibility of the callers. But I could be convinced otherwise!
@@ -204,7 +204,7 @@ export class DashboardStateManager { | |||
FilterUtils.cleanFiltersForComparison(this.appState.filters), | |||
FilterUtils.cleanFiltersForComparison(getFilters(state)) | |||
)) { | |||
store.dispatch(updateFilters(this.appState.filters)); | |||
store.dispatch(updateFilters(_.cloneDeep(this.appState.filters))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this fixes the problem, it indicates that some code is mutating appState.filters
, which seems like the real source of the bug, but also probably too tricky to fix right now. Given that redux expects its state to be immutable, I think we need to change where this fix goes by putting the clone deep in the action helper (updateFilters
). Putting the cloneDeep in the action helper means that any other code that dispatches an updateFilters action will not be victim to the same bug. Does that make sense?
@chrisdavies like this ? |
💚 Build Succeeded |
@@ -17,6 +17,7 @@ | |||
* under the License. | |||
*/ | |||
|
|||
import _ from 'lodash'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe use named import here :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, thanks for fixing this! FWIW, I think adding more typescript would have caught this issue because the redux tree will be marked as readonly.
💚 Build Succeeded |
resolves #20477