@covalent/core 11.4.1 → 11.4.2

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.
package/common/index.d.ts CHANGED
@@ -261,8 +261,13 @@ declare class CovalentTextfieldValueAccessorDirective implements ControlValueAcc
261
261
  writeValue(value: string): void;
262
262
  registerOnChange(fn: any): void;
263
263
  registerOnTouched(fn: any): void;
264
+ /**
265
+ * Gets the updateOn strategy of the control.
266
+ * @returns The updateOn strategy of the control, defaulting to 'change' if not set.
267
+ */
268
+ private getUpdateOn;
264
269
  handleInput(): void;
265
- handleChange(event: Event): void;
270
+ handleChange(): void;
266
271
  handleBlur(): void;
267
272
  setDisabledState(isDisabled: boolean): void;
268
273
  private _isCheckBox;
@@ -2080,7 +2080,6 @@ class CovalentTextfieldValueAccessorDirective {
2080
2080
  this._ngControl.control.statusChanges
2081
2081
  .pipe(takeUntilDestroyed(this._destroyRef))
2082
2082
  .subscribe(() => {
2083
- this._onTouched();
2084
2083
  this._updateValidity();
2085
2084
  });
2086
2085
  }
@@ -2105,24 +2104,36 @@ class CovalentTextfieldValueAccessorDirective {
2105
2104
  registerOnTouched(fn) {
2106
2105
  this._onTouched = fn;
2107
2106
  }
2107
+ /**
2108
+ * Gets the updateOn strategy of the control.
2109
+ * @returns The updateOn strategy of the control, defaulting to 'change' if not set.
2110
+ */
2111
+ getUpdateOn() {
2112
+ return this._ngControl.control?.updateOn || 'change';
2113
+ }
2108
2114
  handleInput() {
2109
- if (!this._isTextAreaOrField()) {
2110
- return;
2115
+ // Update on 'input' event for textfields/textareas if updateOn strategy is 'change'
2116
+ if (this._isTextAreaOrField() && this.getUpdateOn() === 'change') {
2117
+ const value = this._elementRef.nativeElement.value;
2118
+ this._onChange(value);
2111
2119
  }
2112
- const value = this._elementRef.nativeElement.value;
2113
- this._onChange(value);
2114
- this._onTouched();
2115
- this._updateValidity();
2116
2120
  }
2117
- handleChange(event) {
2118
- const value = this._isCheckBox()
2119
- ? this._elementRef.nativeElement.checked
2120
- : this._elementRef.nativeElement.value;
2121
- this._onChange(value);
2122
- this._onTouched();
2123
- this._updateValidity();
2121
+ handleChange() {
2122
+ // For textfields/textareas, handleInput covers 'change' event
2123
+ if (!this._isTextAreaOrField()) {
2124
+ const value = this._isCheckBox()
2125
+ ? this._elementRef.nativeElement.checked
2126
+ : this._elementRef.nativeElement.value;
2127
+ this._onChange(value);
2128
+ this._onTouched();
2129
+ }
2124
2130
  }
2125
2131
  handleBlur() {
2132
+ // For textfields/textareas, update on 'blur' if updateOn strategy is 'blur'
2133
+ if (this._isTextAreaOrField() && this.getUpdateOn() === 'blur') {
2134
+ const value = this._elementRef.nativeElement.value;
2135
+ this._onChange(value);
2136
+ }
2126
2137
  this._onTouched();
2127
2138
  }
2128
2139
  // Optional: If you need to handle disabled states