Matrix cells reset on zoom/reorder
moromis opened this issue · comments
Describe the bug
Matrix cells reset to the original ordering/clustering (clust/clust for row/col) if you zoom after reordering/reclustering.
To Reproduce
Steps to reproduce the behavior:
- Select a new ordering, such as "sum"
- After the heatmap finishes reordering, zoom in -- the matrix cells will reset to their original view
Also:
- Change column ordering to "sum"
- Change ordering again, say to var
- The matrix cells will start from a clust/clust ordering instead of the sum/clust ordering.
Do we know a little bit more about this? I had a brief look into this, but wasn’t able to find the exact root cause.
Unfortunately I don't have an answer. It does seem strange that the correct buffers and arrays and everything gets sent to webgl, everything interpolates, and then it snaps back when you zoom or pan.
The best guess I have is that somehow some state is not properly being set (or in the right order) and either the "new" arrs is not overwriting the "ini" arrs or something similar. Or, we might be resetting the state back to default somewhere? I would start from the interactions, since that seems to be "causing" the reset, and then trace it from there, looking carefully at the state with Redux devtools.
I wonder, if the reassignments of the state could be a factor for this.
In the reducers, I can see quite regularly things like this:
state = action.payload
return state
This mutates the state, instead of returning a new one.
Instead, it should look like this:
return action.payload
EDIT:
I realised, that createSlice
is used, which allows direct access to state
's properties. But, I think, state = action.payload
should just be return action.payload
, as we shouldn't set the state
this way.
Also have been looking a bit more into _.merge
, which seems to be mutable. Seems like one way to go about this might be merge({}, state, action.payload)
. Unfortunately, whilst this seems to work, this is slowing down the whole app.
The final lead to this seems to be remakeMatrixArgs
.
This is part of the camerasManager
and is being called when the opacity slider is moved. Moving the opacity slider before zooming/reordering does prevent any strange behaviour.
The remakeMatrixArgs
needs to be called in the reorderMatrixArgs
for this to work.
I'll create a PR tomorrow morning.