@@ -1254,7 +1254,7 @@ export class IgxQueryBuilderTreeComponent implements AfterViewInit, OnDestroy {
1254
1254
}
1255
1255
1256
1256
//Make a copy of the drag chip and place it in the DOM north or south of the drop chip
1257
- private renderDropGhostChip ( appendToElement : HTMLElement , appendUnder : boolean , keyboardMode ?: boolean , overrideDropUnder ?: boolean ) : void {
1257
+ private renderDropGhostChip ( appendToElement : HTMLElement , appendUnder : boolean , keyboardMode ?: boolean ) : void {
1258
1258
const dragCopy = this . createDropGhost ( keyboardMode ) ;
1259
1259
1260
1260
//Append the ghost
@@ -1274,8 +1274,6 @@ export class IgxQueryBuilderTreeComponent implements AfterViewInit, OnDestroy {
1274
1274
appendToElement . parentNode . insertBefore ( this . dropGhostChipNode , appendToElement . nextElementSibling ) ;
1275
1275
}
1276
1276
1277
- this . dropUnder = overrideDropUnder == null ? this . dropUnder : overrideDropUnder ;
1278
-
1279
1277
//Put focus on the drag icon of the ghost while performing keyboard drag
1280
1278
if ( this . isKeyboardDrag ) {
1281
1279
( ( this . dropGhostChipNode as HTMLElement ) . querySelector ( '.igx-drag-indicator' ) as HTMLElement ) . focus ( ) ;
@@ -1396,52 +1394,27 @@ export class IgxQueryBuilderTreeComponent implements AfterViewInit, OnDestroy {
1396
1394
this . keyDragOffsetIndex = newKeyIndexOffset ;
1397
1395
const indexOffset = ~ ~ ( this . keyDragOffsetIndex / 2 ) ;
1398
1396
1399
- //If not the last drop zone (the +Condition button)
1400
- if ( index + indexOffset <= this . dropZonesList . length - 2 ) {
1401
- const groupsTillCurrent = this . dropZonesList . filter ( ( x , ix ) => ix < index + indexOffset && x . className . indexOf ( 'igx-filter-tree__expression-context-menu' ) !== - 1 ) . length ;
1402
-
1397
+ if ( index + indexOffset <= this . expressionsList . length - 1 ) {
1403
1398
let under = this . keyDragOffsetIndex < 0 ? this . keyDragOffsetIndex % 2 == 0 ? true : false : this . keyDragOffsetIndex % 2 == 0 ? false : true ;
1404
- let overrideDropUnder ;
1405
1399
1406
- //if the current drop zone is a condition chip
1407
1400
if ( this . dropZonesList [ index + indexOffset ] . className . indexOf ( 'igx-filter-tree__expression-context-menu' ) === - 1 ) {
1408
1401
this . targetElement = this . dropZonesList [ index + indexOffset ]
1409
- this . targetExpressionItem = this . expressionsList [ index + indexOffset - groupsTillCurrent ] ;
1402
+ this . targetExpressionItem = this . expressionsList [ index + indexOffset ] ;
1410
1403
} else {
1411
1404
//if the current drop zone is a group root (AND/OR)
1412
1405
if ( index + indexOffset === 0 ) {
1413
1406
//If the root group's AND/OR
1414
1407
this . targetElement = this . dropZonesList [ 0 ]
1415
1408
this . targetExpressionItem = this . rootGroup . children [ 0 ] ;
1416
1409
under = true ;
1417
- overrideDropUnder = false ;
1418
1410
} else if ( under ) {
1419
1411
//If under AND/OR
1420
1412
this . targetElement = this . dropZonesList [ index + indexOffset ]
1421
- this . targetExpressionItem = this . expressionsList [ index + indexOffset - groupsTillCurrent ] ;
1422
- overrideDropUnder = false ;
1413
+ this . targetExpressionItem = this . expressionsList [ index + indexOffset + 1 ] ;
1423
1414
} else {
1424
1415
//if over AND/OR
1425
1416
this . targetElement = this . dropZonesList [ index + indexOffset ] . parentElement . parentElement ;
1426
- const targetEx = this . expressionsList [ index + indexOffset - groupsTillCurrent ] ;
1427
- this . targetExpressionItem = targetEx . parent ? targetEx . parent : targetEx ;
1428
- }
1429
-
1430
- //Calculation of proper targetExpression in case of multiple nested groups
1431
- if ( index + indexOffset !== 0 ) {
1432
- let parentCount = 0 ;
1433
- let item = this . targetExpressionItem ;
1434
- do {
1435
- parentCount ++ ;
1436
- item = item . parent ;
1437
- }
1438
- while ( item . parent ) ;
1439
-
1440
- if ( key . code == 'ArrowDown' ) parentCount -- ;
1441
-
1442
- for ( let index = 0 ; index < parentCount - groupsTillCurrent ; index ++ ) {
1443
- if ( this . targetExpressionItem . parent ) this . targetExpressionItem = this . targetExpressionItem . parent ;
1444
- }
1417
+ this . targetExpressionItem = this . expressionsList [ index + indexOffset ] ;
1445
1418
}
1446
1419
1447
1420
//If should drop under AND/OR => drop over first chip in that AND/OR's group
@@ -1451,13 +1424,12 @@ export class IgxQueryBuilderTreeComponent implements AfterViewInit, OnDestroy {
1451
1424
under = false ;
1452
1425
}
1453
1426
}
1454
-
1455
1427
const before = this . getPreviousChip ( this . dropGhostElement ) ;
1456
1428
const after = this . getNextChip ( this . dropGhostElement ) ;
1457
1429
1458
- this . renderDropGhostChip ( this . targetElement , under , true , overrideDropUnder ) ;
1430
+ this . renderDropGhostChip ( this . targetElement , under , true ) ;
1459
1431
1460
- //If it's the first arrow hit OR drop ghost is not displayed OR hasn't actually moved => move one more step in the same direction
1432
+ //If it's the first arrow hit OR drop ghost is not displayed OR hasn't actually moved, move one more step in the same direction
1461
1433
if ( this . keyDragFirstMove ||
1462
1434
! this . dropGhostElement ||
1463
1435
( this . getPreviousChip ( this . dropGhostElement ) === before && this . getNextChip ( this . dropGhostElement ) === after ) ) {
@@ -1510,10 +1482,11 @@ export class IgxQueryBuilderTreeComponent implements AfterViewInit, OnDestroy {
1510
1482
return nextElement ;
1511
1483
}
1512
1484
1513
- //Get all expressions from the tree flatten out as a list
1485
+ //Get all expressions from the tree flatten out as a list, including the expression groups
1514
1486
private getListedExpressions ( group : ExpressionGroupItem ) : ExpressionItem [ ] {
1515
1487
const expressions : ExpressionItem [ ] = [ ] ;
1516
1488
1489
+ expressions . push ( group ) ;
1517
1490
group . children . forEach ( child => {
1518
1491
if ( child instanceof ExpressionGroupItem ) {
1519
1492
expressions . push ( ...this . getListedExpressions ( child ) ) ;
0 commit comments