Skip to content

Commit

Permalink
Properly size linear genome view after creation
Browse files Browse the repository at this point in the history
  • Loading branch information
cmdcolin committed Oct 31, 2023
1 parent e8cb35c commit 11d5745
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
import { BaseBlock } from '@jbrowse/core/util/blockTypes'
import CompositeMap from '@jbrowse/core/util/compositeMap'
import { getParentRenderProps } from '@jbrowse/core/util/tracks'
import { autorun } from 'mobx'
import { autorun, when } from 'mobx'
import {
addDisposer,
isAlive,
Expand Down Expand Up @@ -305,7 +305,7 @@ function stateModelFactory() {
},
{
label: 'Collapse introns',
onClick: () => {
onClick: async () => {
const { contextMenuFeature } = self
if (contextMenuFeature) {
const refName = contextMenuFeature.get('refName')
Expand All @@ -323,11 +323,24 @@ function stateModelFactory() {
assemblyName: view.assemblyNames[0],
})) || []
res.sort((a, b) => a.start - b.start)
getSession(self).addView('LinearGenomeView', {
...getSnapshot(view),
id: nanoid(),
displayedRegions: res,
})

// need to strip ID before copying view snap
const { id, ...rest } = getSnapshot(view)
const newView = getSession(self).addView(
'LinearGenomeView',
{
...rest,
id: nanoid(),
tracks: rest.tracks.map(track => {
const { id, ...rest } = track
return { ...rest, id: nanoid() }
}),
displayedRegions: res,
},
) as LGV
await when(() => newView.initialized)

newView.showAllRegions()
}
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,11 @@ const Controls = ({ model }: { model: LGV }) => {
}

const LinearGenomeViewHeader = observer(({ model }: { model: LGV }) => {
const Wrapper = model.hideHeaderOverview ? React.Fragment : OverviewScalebar
return !model.hideHeader ? (
model.hideHeaderOverview ? (
<Wrapper model={model}>
<Controls model={model} />
) : (
<OverviewScalebar model={model}>
<Controls model={model} />
</OverviewScalebar>
)
</Wrapper>
) : null
})

Expand Down

0 comments on commit 11d5745

Please sign in to comment.