@syncfusion/ej2-querybuilder 32.2.8 → 32.2.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4218,9 +4218,18 @@ let QueryBuilder = class QueryBuilder extends Component {
4218
4218
  if (this.groupCloned && this.target instanceof HTMLElement &&
4219
4219
  this.getGroup(this.target).rules.length > 1) {
4220
4220
  const parent = this.element.querySelector('#' + groupID);
4221
+ const allContainers = parent.querySelectorAll(':scope > .e-group-body > .e-rule-list > [class*="-container"]');
4221
4222
  const topLevelGroups = parent.querySelectorAll(':scope > .e-group-body > .e-rule-list > .e-group-container');
4222
- if (groupID !== 'querybuilder_group0' && !(this.isAngular && groupID === 'ej2-querybuilder_0_group0')) {
4223
- this.groupIndex = topLevelGroups.length > 1 ? topLevelGroups.length - 1 : 0;
4223
+ if (topLevelGroups.length > 0 && groupID !== 'querybuilder_group0' && !(this.isAngular && groupID === 'ej2-querybuilder_0_group0')) {
4224
+ let lastGroupIndex = -1;
4225
+ const lastGroup = topLevelGroups[topLevelGroups.length - 1];
4226
+ for (let i = 0; i < allContainers.length; i++) {
4227
+ if (allContainers[i] === lastGroup) {
4228
+ lastGroupIndex = i;
4229
+ break;
4230
+ }
4231
+ }
4232
+ this.groupIndex = lastGroupIndex - 1;
4224
4233
  }
4225
4234
  }
4226
4235
  if (this.groupIndex < 0) {