@angular/material 14.0.0-rc.2 → 14.0.0

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.
@@ -2480,6 +2480,21 @@ class MatDatepickerBase {
2480
2480
  }
2481
2481
  this.close();
2482
2482
  });
2483
+ // The `preventDefault` call happens inside the calendar as well, however focus moves into
2484
+ // it inside a timeout which can give browsers a chance to fire off a keyboard event in-between
2485
+ // that can scroll the page (see #24969). Always block default actions of arrow keys for the
2486
+ // entire overlay so the page doesn't get scrolled by accident.
2487
+ overlayRef.keydownEvents().subscribe(event => {
2488
+ const keyCode = event.keyCode;
2489
+ if (keyCode === UP_ARROW ||
2490
+ keyCode === DOWN_ARROW ||
2491
+ keyCode === LEFT_ARROW ||
2492
+ keyCode === RIGHT_ARROW ||
2493
+ keyCode === PAGE_UP ||
2494
+ keyCode === PAGE_DOWN) {
2495
+ event.preventDefault();
2496
+ }
2497
+ });
2483
2498
  this._componentRef = overlayRef.attach(portal);
2484
2499
  this._forwardContentValues(this._componentRef.instance);
2485
2500
  // Update the position once the calendar has rendered. Only relevant in dropdown mode.