@@ -275,25 +275,23 @@ export class IgxPivotHeaderRowComponent extends IgxGridHeaderRowComponent {
275275 . concat ( this . grid . pivotConfiguration . columns )
276276 . concat ( this . grid . pivotConfiguration . filters ) ;
277277 // chip moved from external collection
278- const dims = allDims . filter ( x => x && x . memberName === dragId ) ;
279- if ( dims . length === 0 ) {
278+ const dim = allDims . find ( x => x && x . memberName === dragId ) ;
279+ if ( ! dim ) {
280280 // you have dragged something that is not a dimension
281281 return ;
282282 }
283- dims . forEach ( element => {
284- element . enabled = false ;
285- } ) ;
286-
283+ const dimType = this . getDimensionsType ( dim ) ;
287284 const currentDimChild = currentDim . find ( x => x && x . memberName === dragId ) ;
288285 if ( currentDimChild ) {
289286 currentDimChild . enabled = true ;
290287 const dragChipIndex = currentDim . indexOf ( currentDimChild ) ;
291288 currentDim . splice ( dragChipIndex , 1 ) ;
292289 currentDim . splice ( dragChipIndex > chipIndex ? targetIndex : targetIndex - 1 , 0 , currentDimChild ) ;
293290 } else {
294- const newDim = Object . assign ( { } , dims [ 0 ] ) ;
295- newDim . enabled = true ;
296- currentDim . splice ( targetIndex , 0 , newDim ) ;
291+ const prevDimensionCollection = this . getDimensionsByType ( dimType ) ;
292+ // delete from previous dimension collection and add to current.
293+ prevDimensionCollection . splice ( prevDimensionCollection . indexOf ( dim ) , 1 ) ;
294+ currentDim . splice ( targetIndex , 0 , dim ) ;
297295 }
298296 const isDraggedFromColumn = ! ! this . grid . pivotConfiguration . columns ?. find ( x => x && x . memberName === dragId ) ;
299297 if ( isDraggedFromColumn ) {
@@ -341,6 +339,12 @@ export class IgxPivotHeaderRowComponent extends IgxGridHeaderRowComponent {
341339 }
342340 }
343341
342+ protected getDimensionsType ( dimension : IPivotDimension ) {
343+ const isColumn = ! ! this . grid . pivotConfiguration . columns ?. find ( x => x && x . memberName === dimension . memberName ) ;
344+ const isRow = ! ! this . grid . pivotConfiguration . rows ?. find ( x => x && x . memberName === dimension . memberName ) ;
345+ return isColumn ? PivotDimensionType . Column : isRow ? PivotDimensionType . Row : PivotDimensionType . Filter ;
346+ }
347+
344348 protected getAggregatorsForValue ( value : IPivotValue ) : IPivotAggregator [ ] {
345349 const dataType = value . dataType || this . grid . resolveDataTypes ( this . grid . data [ 0 ] [ value . member ] ) ;
346350 switch ( dataType ) {
0 commit comments