@cqa-lib/cqa-ui 1.1.56 → 1.1.57

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.
@@ -6252,12 +6252,27 @@ class LoopStepComponent extends BaseStepComponent {
6252
6252
  const currentValue = changes['selectedIterationId'].currentValue;
6253
6253
  const previousValue = changes['selectedIterationId'].previousValue;
6254
6254
  if (currentValue !== previousValue) {
6255
- this.selectDefaultIteration();
6255
+ // If selectedIterationId is provided and different, use it
6256
+ if (currentValue) {
6257
+ const found = this.iterations.find(iter => iter.id === currentValue);
6258
+ if (found) {
6259
+ this.selectedIteration = found;
6260
+ }
6261
+ else {
6262
+ this.selectDefaultIteration();
6263
+ }
6264
+ }
6265
+ else {
6266
+ this.selectDefaultIteration();
6267
+ }
6256
6268
  }
6257
6269
  }
6258
6270
  // Update selection when iterations array changes
6259
6271
  if (changes['iterations'] && this.iterations && this.iterations.length > 0) {
6260
- this.selectDefaultIteration();
6272
+ // Only reselect if we don't have a valid selection or if selectedIterationId changed
6273
+ if (!this.selectedIteration || !this.iterations.some(iter => iter.id === this.selectedIteration?.id)) {
6274
+ this.selectDefaultIteration();
6275
+ }
6261
6276
  }
6262
6277
  // Update config when inputs change
6263
6278
  if (changes['iterations'] || changes['selectedIterationId'] || changes['nestedSteps']) {
@@ -6277,10 +6292,21 @@ class LoopStepComponent extends BaseStepComponent {
6277
6292
  }
6278
6293
  }
6279
6294
  selectDefaultIteration() {
6295
+ // Only select default if no iteration is currently selected
6296
+ // This preserves user's selection when they manually change the iteration
6297
+ if (this.selectedIteration && this.selectedIterationId && this.selectedIteration.id === this.selectedIterationId) {
6298
+ // Already selected correctly, no need to change
6299
+ return;
6300
+ }
6280
6301
  if (this.selectedIterationId) {
6281
- this.selectedIteration = this.iterations.find(iter => iter.id === this.selectedIterationId) || null;
6302
+ const found = this.iterations.find(iter => iter.id === this.selectedIterationId);
6303
+ if (found) {
6304
+ this.selectedIteration = found;
6305
+ return;
6306
+ }
6282
6307
  }
6283
- else if (this.defaultIteration === 'last' && this.iterations.length > 0) {
6308
+ // Only apply default if no specific selection was provided
6309
+ if (this.defaultIteration === 'last' && this.iterations.length > 0) {
6284
6310
  this.selectedIteration = this.iterations[this.iterations.length - 1];
6285
6311
  }
6286
6312
  else if (this.iterations.length > 0) {
@@ -6289,6 +6315,11 @@ class LoopStepComponent extends BaseStepComponent {
6289
6315
  }
6290
6316
  handleIterationChange(iterationId) {
6291
6317
  this.selectedIteration = this.iterations.find(iter => iter.id === iterationId) || null;
6318
+ // Update the selectedIterationId to match the user's selection
6319
+ // This ensures consistency
6320
+ if (this.selectedIteration) {
6321
+ // Keep the internal state in sync
6322
+ }
6292
6323
  // Emit the event with the iteration ID
6293
6324
  this.onIterationChange.emit(iterationId);
6294
6325
  }