Skip to content

Conversation

@victorlin
Copy link
Member

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

Previously, this did not work because the dispatch to reset layout was
conditional on having a CDS selected.
@victorlin victorlin requested a review from jameshadfield March 28, 2025 17:44
if (arg === nucleotide_gene) {
if (entropy.selectedCds === nucleotide_gene) {
return
}
Copy link
Member

Choose a reason for hiding this comment

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

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.

Copy link
Member Author

Choose a reason for hiding this comment

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

Simply dropping action.selectedPositions = [] doesn't work, I think because zoom bounds are tightly coupled with selected positions here:

if (this.selectedPositions?.length) {
const posMin = Math.min(...this.selectedPositions);
const posMax = Math.max(...this.selectedPositions);
/* If we already have coordinates which are not the default, and the new
positions are within the coordinates, then don't change zoom at all */
if (
this.zoomCoordinates &&
(this.zoomCoordinates[0]!==domain[0] || this.zoomCoordinates[1]!==domain[1]) &&
posMin>this.zoomCoordinates[0] && posMax<this.zoomCoordinates[1]
) {
return;
}
let desiredSurroundingSpace = Math.floor(domain[1] * 0.05); // 5%
if (desiredSurroundingSpace>1000) desiredSurroundingSpace=1000; // up to a max of 1kb
this.zoomCoordinates = [posMin - desiredSurroundingSpace, posMax + desiredSurroundingSpace];

} else {
this.props.dispatch(changeEntropyCdsSelection(nucleotide_gene));
}
this.props.dispatch(changeEntropyCdsSelection(nucleotide_gene));
Copy link
Member

Choose a reason for hiding this comment

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

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.

Copy link
Member Author

Choose a reason for hiding this comment

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

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.

@victorlin victorlin temporarily deployed to auspice-victorlin-fix-e-qpulhc April 9, 2025 00:33 Inactive
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Reset layout in entropy view has no effect when URL params are set: either disable button in that case, or make it override URL params

5 participants