@ascentgl/ads-ui 21.64.0 → 21.64.1

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.
@@ -2444,18 +2444,25 @@ class AbstractBaseComponent {
2444
2444
  if (this.valueControl.errors) {
2445
2445
  this.valueControl.setErrors(null);
2446
2446
  }
2447
+ // hadRequiredValidator stays as is - we remember if it was required originally
2447
2448
  }
2448
2449
  else {
2449
2450
  // When non-empty -> restore validators.
2450
2451
  this.valueControl.setValidators(this.originalValidator);
2451
2452
  this.valueControl.setAsyncValidators(this.originalAsyncValidator);
2453
+ // Don't update hadRequiredValidator here - it was set from originalValidator initially
2452
2454
  }
2453
2455
  }, 0);
2454
2456
  });
2455
2457
  // Subscribe to status changes to update hadRequiredValidator when validators are externally added/removed
2456
2458
  // This ensures the asterisk is correctly shown/hidden after addValidators/removeValidators calls
2459
+ // But skip updates during skipValidationWhenEmpty mode where validators are managed internally
2457
2460
  const statusSub = this.valueControl.statusChanges.subscribe(() => {
2458
- this.hadRequiredValidator = this.valueControl.hasValidator(Validators.required);
2461
+ // Only update hadRequiredValidator if we're not in skipValidationWhenEmpty mode
2462
+ // When skipValidationWhenEmpty is active, we preserve the original validator state
2463
+ if (!this.skipValidationWhenEmpty) {
2464
+ this.hadRequiredValidator = this.valueControl.hasValidator(Validators.required);
2465
+ }
2459
2466
  });
2460
2467
  this.destroyRef.onDestroy(() => {
2461
2468
  subscription.unsubscribe();
@@ -2469,10 +2476,9 @@ class AbstractBaseComponent {
2469
2476
  }
2470
2477
  /** @ignore */
2471
2478
  get required() {
2472
- // When skipValidationWhenEmpty is active and value is empty, validators are temporarily removed.
2473
- // In that case, use hadRequiredValidator to preserve the asterisk.
2474
- // Otherwise, check the actual current validator state.
2475
- if (this.skipValidationWhenEmpty && this.isEmptyValue(this.valueControl.value)) {
2479
+ // When skipValidationWhenEmpty is active, always use hadRequiredValidator to preserve the asterisk
2480
+ // regardless of whether the value is empty or not, because validators may be temporarily removed.
2481
+ if (this.skipValidationWhenEmpty) {
2476
2482
  return this.hadRequiredValidator;
2477
2483
  }
2478
2484
  return this.valueControl.hasValidator(Validators.required);