Skip to content

Commit 5649175

Browse files
committed
fix(angular/menu): not interrupting keyboard events to other overlays
angular/components#23310
1 parent 65a79cc commit 5649175

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

src/angular/menu/menu.spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,13 +452,15 @@ describe('SbbMenu', () => {
452452

453453
const panel = overlayContainerElement.querySelector('.sbb-menu-panel-wrapper')!;
454454
const event = createKeyboardEvent('keydown', ESCAPE);
455+
spyOn(event, 'stopPropagation').and.callThrough();
455456

456457
dispatchEvent(panel, event);
457458
fixture.detectChanges();
458459
tick(500);
459460

460461
expect(overlayContainerElement.textContent).toBe('');
461462
expect(event.defaultPrevented).toBe(true);
463+
expect(event.stopPropagation).toHaveBeenCalled();
462464
}));
463465

464466
it('should not close the menu when pressing ESCAPE with a modifier', fakeAsync(() => {

src/angular/menu/menu.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,12 @@ export class SbbMenu implements AfterContentInit, SbbMenuPanel<SbbMenuItem>, OnI
324324
}
325325

326326
manager.onKeydown(event);
327+
return;
327328
}
329+
330+
// Don't allow the event to propagate if we've already handled it, or it may
331+
// end up reaching other overlays that were opened earlier (see #22694).
332+
event.stopPropagation();
328333
}
329334

330335
/** Whether to display the menu header which mirrors the trigger content. */

0 commit comments

Comments
 (0)