(event: Event)
| 324 | } |
| 325 | |
| 326 | _onInput(event: Event) { |
| 327 | const value = (event.target as HTMLInputElement).value; |
| 328 | const lastValueWasValid = this._lastValueValid; |
| 329 | let date = this._dateAdapter.parse(value, this._dateFormats.parse.dateInput); |
| 330 | this._lastValueValid = this._isValidValue(date); |
| 331 | date = this._dateAdapter.getValidDateOrNull(date); |
| 332 | const hasChanged = !this._dateAdapter.sameDate(date, this.value); |
| 333 | |
| 334 | // We need to fire the CVA change event for all |
| 335 | // nulls, otherwise the validators won't run. |
| 336 | if (!date || hasChanged) { |
| 337 | this._cvaOnChange(date); |
| 338 | } else { |
| 339 | // Call the CVA change handler for invalid values |
| 340 | // since this is what marks the control as dirty. |
| 341 | if (value && !this.value) { |
| 342 | this._cvaOnChange(date); |
| 343 | } |
| 344 | } |
| 345 | |
| 346 | // Re-run the validators if the parse state changed while the value stayed the same. |
| 347 | // This also covers going from one null to another (e.g. clearing an unparseable value), |
| 348 | // because signal forms skip value writes that don't change the value. |
| 349 | if (!hasChanged && lastValueWasValid !== this._lastValueValid) { |
| 350 | this._validatorOnChange(); |
| 351 | } |
| 352 | |
| 353 | if (hasChanged) { |
| 354 | this._assignValue(date); |
| 355 | this.dateInput.emit(new MatDatepickerInputEvent(this, this._elementRef.nativeElement)); |
| 356 | } |
| 357 | } |
| 358 | |
| 359 | _onChange() { |
| 360 | this.dateChange.emit(new MatDatepickerInputEvent(this, this._elementRef.nativeElement)); |
nothing calls this directly
no test coverage detected