@@ -1123,7 +1123,7 @@ class GraphConnection extends SegmentationGraphSourceConnection {
11231123    annotationLayerStates . push ( redGroup ,  blueGroup ) ; 
11241124
11251125    if  ( layer . tool . value  instanceof  MergeSegmentsPlaceLineTool )  { 
1126-       layer . tool . value  =  undefined ; 
1126+       layer . tool . value  =  undefined ;   // unset the line tool if it is active when page is loaded 
11271127    } 
11281128
11291129    this . mergeAnnotationState  =  makeColoredAnnotationState ( 
@@ -2394,18 +2394,27 @@ class MergeSegmentsTool extends LayerTool<SegmentationUserLayer> {
23942394      return ; 
23952395    const  { 
23962396      state : {  mergeState } , 
2397+       mergeAnnotationState, 
23972398    }  =  graphConnection ; 
2398-     if  ( mergeState  ===  undefined )  return ; 
2399-     const  {  merges,  autoSubmit }  =  mergeState ; 
2400- 
24012399    const  lineTool  =  new  MergeSegmentsPlaceLineTool ( 
24022400      this . layer , 
2403-       graphConnection . mergeAnnotationState , 
2401+       mergeAnnotationState , 
24042402    ) ; 
2403+     // Switch selected layer to the layer associated with the tool 
2404+     // to enable to place line tool. Swap back when deactivating. 
2405+     const  {  selectedLayer }  =  this . layer . manager . root ; 
2406+     const  previousSelectedLayer  =  selectedLayer . layer ; 
2407+     const  previousSelectedLayerVisible  =  selectedLayer . visible ; 
2408+     const  previousTool  =  tool . value ; 
2409+     selectedLayer . layer  =  this . layer . managedLayer ; 
2410+     selectedLayer . visible  =  true ; 
24052411    tool . value  =  lineTool ; 
24062412    activation . registerDisposer ( ( )  =>  { 
2407-       tool . value  =  undefined ; 
2413+       selectedLayer . layer  =  previousSelectedLayer ; 
2414+       selectedLayer . visible  =  previousSelectedLayerVisible ; 
2415+       tool . value  =  previousTool ; 
24082416    } ) ; 
2417+     const  {  merges,  autoSubmit }  =  mergeState ; 
24092418    const  {  body,  header }  = 
24102419      makeToolActivationStatusMessageWithHeader ( activation ) ; 
24112420    header . textContent  =  "Merge segments" ; 
0 commit comments