@cqa-lib/cqa-ui 1.1.56 → 1.1.58

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.
@@ -6222,6 +6222,7 @@ class LoopStepComponent extends BaseStepComponent {
6222
6222
  // Output event for when iteration selection changes
6223
6223
  this.onIterationChange = new EventEmitter();
6224
6224
  this.selectedIteration = null;
6225
+ this.userSelectedIterationId = null; // Track user's manual selection
6225
6226
  }
6226
6227
  ngOnInit() {
6227
6228
  // Build config from individual inputs
@@ -6252,12 +6253,50 @@ class LoopStepComponent extends BaseStepComponent {
6252
6253
  const currentValue = changes['selectedIterationId'].currentValue;
6253
6254
  const previousValue = changes['selectedIterationId'].previousValue;
6254
6255
  if (currentValue !== previousValue) {
6255
- this.selectDefaultIteration();
6256
+ // If user has manually selected an iteration, don't override it unless the input matches
6257
+ if (this.userSelectedIterationId && this.userSelectedIterationId === currentValue) {
6258
+ // Input matches user's selection, keep it
6259
+ const found = this.iterations.find(iter => iter.id === currentValue);
6260
+ if (found) {
6261
+ this.selectedIteration = found;
6262
+ }
6263
+ }
6264
+ else if (!this.userSelectedIterationId) {
6265
+ // No user selection, use the input value
6266
+ if (currentValue) {
6267
+ const found = this.iterations.find(iter => iter.id === currentValue);
6268
+ if (found) {
6269
+ this.selectedIteration = found;
6270
+ }
6271
+ else {
6272
+ this.selectDefaultIteration();
6273
+ }
6274
+ }
6275
+ else {
6276
+ this.selectDefaultIteration();
6277
+ }
6278
+ }
6279
+ // If input doesn't match user selection, don't override user's choice
6256
6280
  }
6257
6281
  }
6258
6282
  // Update selection when iterations array changes
6259
6283
  if (changes['iterations'] && this.iterations && this.iterations.length > 0) {
6260
- this.selectDefaultIteration();
6284
+ // Only reselect if we don't have a valid selection or if selectedIterationId changed
6285
+ if (!this.selectedIteration || !this.iterations.some(iter => iter.id === this.selectedIteration?.id)) {
6286
+ // If user has selected something, try to preserve it
6287
+ if (this.userSelectedIterationId) {
6288
+ const found = this.iterations.find(iter => iter.id === this.userSelectedIterationId);
6289
+ if (found) {
6290
+ this.selectedIteration = found;
6291
+ }
6292
+ else {
6293
+ this.selectDefaultIteration();
6294
+ }
6295
+ }
6296
+ else {
6297
+ this.selectDefaultIteration();
6298
+ }
6299
+ }
6261
6300
  }
6262
6301
  // Update config when inputs change
6263
6302
  if (changes['iterations'] || changes['selectedIterationId'] || changes['nestedSteps']) {
@@ -6277,10 +6316,21 @@ class LoopStepComponent extends BaseStepComponent {
6277
6316
  }
6278
6317
  }
6279
6318
  selectDefaultIteration() {
6319
+ // Only select default if no iteration is currently selected
6320
+ // This preserves user's selection when they manually change the iteration
6321
+ if (this.selectedIteration && this.selectedIterationId && this.selectedIteration.id === this.selectedIterationId) {
6322
+ // Already selected correctly, no need to change
6323
+ return;
6324
+ }
6280
6325
  if (this.selectedIterationId) {
6281
- this.selectedIteration = this.iterations.find(iter => iter.id === this.selectedIterationId) || null;
6326
+ const found = this.iterations.find(iter => iter.id === this.selectedIterationId);
6327
+ if (found) {
6328
+ this.selectedIteration = found;
6329
+ return;
6330
+ }
6282
6331
  }
6283
- else if (this.defaultIteration === 'last' && this.iterations.length > 0) {
6332
+ // Only apply default if no specific selection was provided
6333
+ if (this.defaultIteration === 'last' && this.iterations.length > 0) {
6284
6334
  this.selectedIteration = this.iterations[this.iterations.length - 1];
6285
6335
  }
6286
6336
  else if (this.iterations.length > 0) {
@@ -6288,6 +6338,8 @@ class LoopStepComponent extends BaseStepComponent {
6288
6338
  }
6289
6339
  }
6290
6340
  handleIterationChange(iterationId) {
6341
+ // Store the user's manual selection
6342
+ this.userSelectedIterationId = iterationId;
6291
6343
  this.selectedIteration = this.iterations.find(iter => iter.id === iterationId) || null;
6292
6344
  // Emit the event with the iteration ID
6293
6345
  this.onIterationChange.emit(iterationId);