Reset layout when nucleotide position is selected#1947
Conversation
Previously, this did not work because the dispatch to reset layout was conditional on having a CDS selected.
| if (arg === nucleotide_gene) { | ||
| if (entropy.selectedCds === nucleotide_gene) { | ||
| return | ||
| } |
There was a problem hiding this comment.
If you've highlighted a nucleotide bar (in the entropy panel) and click "reset layout" the bar will no longer be highlighted because now action.selectedPositions = []; will be hit below.
There was a problem hiding this comment.
Simply dropping action.selectedPositions = [] doesn't work, I think because zoom bounds are tightly coupled with selected positions here:
auspice/src/components/entropy/entropyD3.js
Lines 131 to 145 in 1f40cd0
| } else { | ||
| this.props.dispatch(changeEntropyCdsSelection(nucleotide_gene)); | ||
| } | ||
| this.props.dispatch(changeEntropyCdsSelection(nucleotide_gene)); |
There was a problem hiding this comment.
With this change (and the earlier change), the following just above this line becomes unnecessary and can be removed:
if (viewingGenome) {
this.state.chart.update({
zoomMin: this.state.chart.zoomBounds[0],
zoomMax: this.state.chart.zoomBounds[1],
})
}This is because we end up running update({selectedPositions: []}) which runs
if (selectedCds || selectedPositions !== undefined) {
this._setZoomCoordinates(zoomMin, zoomMax, !!selectedCds);
}so we'll always reset the coordinates to show the entire nuc span.
There was a problem hiding this comment.
It's still used for when no CDS or position is selected, when the min/max sliders are adjusted. I think the update can happen elsewhere though. Started with 1f40cd0 but haven't gotten it fully working.
Description of proposed changes
Previously, this did not work because the dispatch to reset layout was conditional on having a CDS selected.
Related issue(s)
Closes #1774
Checklist