@@ -16,7 +16,7 @@ import {
16
16
import { BaseBlock } from '@jbrowse/core/util/blockTypes'
17
17
import CompositeMap from '@jbrowse/core/util/compositeMap'
18
18
import { getParentRenderProps } from '@jbrowse/core/util/tracks'
19
- import { autorun } from 'mobx'
19
+ import { autorun , when } from 'mobx'
20
20
import {
21
21
addDisposer ,
22
22
isAlive ,
@@ -305,7 +305,7 @@ function stateModelFactory() {
305
305
} ,
306
306
{
307
307
label : 'Collapse introns' ,
308
- onClick : ( ) => {
308
+ onClick : async ( ) => {
309
309
const { contextMenuFeature } = self
310
310
if ( contextMenuFeature ) {
311
311
const refName = contextMenuFeature . get ( 'refName' )
@@ -323,11 +323,24 @@ function stateModelFactory() {
323
323
assemblyName : view . assemblyNames [ 0 ] ,
324
324
} ) ) || [ ]
325
325
res . sort ( ( a , b ) => a . start - b . start )
326
- getSession ( self ) . addView ( 'LinearGenomeView' , {
327
- ...getSnapshot ( view ) ,
328
- id : nanoid ( ) ,
329
- displayedRegions : res ,
330
- } )
326
+
327
+ // need to strip ID before copying view snap
328
+ const { id, ...rest } = getSnapshot ( view )
329
+ const newView = getSession ( self ) . addView (
330
+ 'LinearGenomeView' ,
331
+ {
332
+ ...rest ,
333
+ id : nanoid ( ) ,
334
+ tracks : rest . tracks . map ( track => {
335
+ const { id, ...rest } = track
336
+ return { ...rest , id : nanoid ( ) }
337
+ } ) ,
338
+ displayedRegions : res ,
339
+ } ,
340
+ ) as LGV
341
+ await when ( ( ) => newView . initialized )
342
+
343
+ newView . showAllRegions ( )
331
344
}
332
345
} ,
333
346
} ,
0 commit comments