File tree Expand file tree Collapse file tree 2 files changed +11
-0
lines changed 
packages/components/grid/src Expand file tree Collapse file tree 2 files changed +11
-0
lines changed Original file line number Diff line number Diff line change 1+ --- 
2+ ' @sl-design-system/grid ' patch 
3+ --- 
4+ 
5+ Reset the selection state when the data source is replaced
Original file line number Diff line number Diff line change @@ -219,6 +219,8 @@ export class Grid<T = any> extends ScopedElementsMixin(LitElement) {
219219  /** Provide your own implementation for getting the data. */ 
220220  @property ( {  attribute : false  } ) 
221221  set  dataSource ( dataSource : ListDataSource < T >  |  undefined )  { 
222+     const  replacement  =  ! ! this . #dataSource; 
223+ 
222224    if  ( this . #dataSource)  { 
223225      this . #dataSource. removeEventListener ( 'sl-update' ,  this . #onDataSourceUpdate) ; 
224226      this . #dataSource. removeEventListener ( 'sl-selection-change' ,  this . #onSelectionChange) ; 
@@ -227,6 +229,10 @@ export class Grid<T = any> extends ScopedElementsMixin(LitElement) {
227229    this . #dataSource =  dataSource ; 
228230    this . #dataSource?. addEventListener ( 'sl-update' ,  this . #onDataSourceUpdate) ; 
229231    this . #dataSource?. addEventListener ( 'sl-selection-change' ,  this . #onSelectionChange) ; 
232+ 
233+     if  ( replacement )  { 
234+       this . #onSelectionChange( ) ; 
235+     } 
230236  } 
231237
232238  /** 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments