@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.
@@ -2374,6 +2374,21 @@ class MatDatepickerBase {
2374
2374
  }
2375
2375
  this.close();
2376
2376
  });
2377
+ // The `preventDefault` call happens inside the calendar as well, however focus moves into
2378
+ // it inside a timeout which can give browsers a chance to fire off a keyboard event in-between
2379
+ // that can scroll the page (see #24969). Always block default actions of arrow keys for the
2380
+ // entire overlay so the page doesn't get scrolled by accident.
2381
+ overlayRef.keydownEvents().subscribe(event => {
2382
+ const keyCode = event.keyCode;
2383
+ if (keyCode === UP_ARROW ||
2384
+ keyCode === DOWN_ARROW ||
2385
+ keyCode === LEFT_ARROW ||
2386
+ keyCode === RIGHT_ARROW ||
2387
+ keyCode === PAGE_UP ||
2388
+ keyCode === PAGE_DOWN) {
2389
+ event.preventDefault();
2390
+ }
2391
+ });
2377
2392
  this._componentRef = overlayRef.attach(portal);
2378
2393
  this._forwardContentValues(this._componentRef.instance);
2379
2394
  // Update the position once the calendar has rendered. Only relevant in dropdown mode.
@@ -2748,9 +2763,8 @@ class MatDatepickerInputBase {
2748
2763
  }
2749
2764
  /** Formats a value and sets it on the input element. */
2750
2765
  _formatValue(value) {
2751
- this._elementRef.nativeElement.value = value
2752
- ? this._dateAdapter.format(value, this._dateFormats.display.dateInput)
2753
- : '';
2766
+ this._elementRef.nativeElement.value =
2767
+ value != null ? this._dateAdapter.format(value, this._dateFormats.display.dateInput) : '';
2754
2768
  }
2755
2769
  /** Assigns a value to the model. */
2756
2770
  _assignValue(value) {