MCPcopy Create free account
hub / github.com/angular/components / toggle

Method toggle

src/material/sidenav/drawer.ts:559–577  ·  view source on GitHub ↗

* Toggle this drawer. * @param isOpen Whether the drawer should be open. * @param openedVia Whether the drawer was opened by a key press, mouse click or programmatically. * Used for focus management after the sidenav is closed.

(isOpen: boolean = !this.opened, openedVia?: FocusOrigin)

Source from the content-addressed store, hash-verified

557 * Used for focus management after the sidenav is closed.
558 */
559 toggle(isOpen: boolean = !this.opened, openedVia?: FocusOrigin): Promise<MatDrawerToggleResult> {
560 // If the focus is currently inside the drawer content and we are closing the drawer,
561 // restore the focus to the initially focused element (when the drawer opened).
562 if (isOpen && openedVia) {
563 this._openedVia = openedVia;
564 }
565
566 const result = this._setOpen(
567 isOpen,
568 /* restoreFocus */ !isOpen && this._isFocusWithinDrawer(),
569 this._openedVia || 'program',
570 );
571
572 if (!isOpen) {
573 this._openedVia = null;
574 }
575
576 return result;
577 }
578
579 /**
580 * Toggles the opened state of the drawer.

Callers 3

openedMethod · 0.95
openMethod · 0.95
closeMethod · 0.95

Calls 2

_setOpenMethod · 0.95
_isFocusWithinDrawerMethod · 0.95

Tested by

no test coverage detected