@angular/material 13.3.6 → 13.3.9

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.
@@ -2368,6 +2368,21 @@ class MatDatepickerBase {
2368
2368
  }
2369
2369
  this.close();
2370
2370
  });
2371
+ // The `preventDefault` call happens inside the calendar as well, however focus moves into
2372
+ // it inside a timeout which can give browsers a chance to fire off a keyboard event in-between
2373
+ // that can scroll the page (see #24969). Always block default actions of arrow keys for the
2374
+ // entire overlay so the page doesn't get scrolled by accident.
2375
+ overlayRef.keydownEvents().subscribe(event => {
2376
+ const keyCode = event.keyCode;
2377
+ if (keyCode === UP_ARROW ||
2378
+ keyCode === DOWN_ARROW ||
2379
+ keyCode === LEFT_ARROW ||
2380
+ keyCode === RIGHT_ARROW ||
2381
+ keyCode === PAGE_UP ||
2382
+ keyCode === PAGE_DOWN) {
2383
+ event.preventDefault();
2384
+ }
2385
+ });
2371
2386
  this._componentRef = overlayRef.attach(portal);
2372
2387
  this._forwardContentValues(this._componentRef.instance);
2373
2388
  // Update the position once the calendar has rendered. Only relevant in dropdown mode.
@@ -2740,9 +2755,8 @@ class MatDatepickerInputBase {
2740
2755
  }
2741
2756
  /** Formats a value and sets it on the input element. */
2742
2757
  _formatValue(value) {
2743
- this._elementRef.nativeElement.value = value
2744
- ? this._dateAdapter.format(value, this._dateFormats.display.dateInput)
2745
- : '';
2758
+ this._elementRef.nativeElement.value =
2759
+ value != null ? this._dateAdapter.format(value, this._dateFormats.display.dateInput) : '';
2746
2760
  }
2747
2761
  /** Assigns a value to the model. */
2748
2762
  _assignValue(value) {