From 36c627beaff2dc486997d1954b36989400591dc5 Mon Sep 17 00:00:00 2001 From: Kristiyan Kostadinov Date: Thu, 20 Jun 2024 21:35:30 +0200 Subject: [PATCH] fix(material/sidenav): not closing on escape key press (#29292) Fixes that the sidenav wasn't triggering change detection when closing via a escape key press. --- src/material/sidenav/drawer.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/material/sidenav/drawer.ts b/src/material/sidenav/drawer.ts index 1936d4cdb0ae..175d29f1ee38 100644 --- a/src/material/sidenav/drawer.ts +++ b/src/material/sidenav/drawer.ts @@ -322,6 +322,7 @@ export class MatDrawer implements AfterViewInit, AfterContentChecked, OnDestroy readonly _modeChanged = new Subject(); private _injector = inject(Injector); + private _changeDetectorRef = inject(ChangeDetectorRef); constructor( private _elementRef: ElementRef, @@ -593,6 +594,8 @@ export class MatDrawer implements AfterViewInit, AfterContentChecked, OnDestroy } } + // Needed to ensure that the closing sequence fires off correctly. + this._changeDetectorRef.markForCheck(); this._updateFocusTrapState(); return new Promise(resolve => {