MCPcopy Index your code
hub / github.com/angular/components / toggle

Method toggle

src/material/sidenav/drawer.ts:551–569  ·  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

549 * Used for focus management after the sidenav is closed.
550 */
551 toggle(isOpen: boolean = !this.opened, openedVia?: FocusOrigin): Promise<MatDrawerToggleResult> {
552 // If the focus is currently inside the drawer content and we are closing the drawer,
553 // restore the focus to the initially focused element (when the drawer opened).
554 if (isOpen && openedVia) {
555 this._openedVia = openedVia;
556 }
557
558 const result = this._setOpen(
559 isOpen,
560 /* restoreFocus */ !isOpen && this._isFocusWithinDrawer(),
561 this._openedVia || 'program',
562 );
563
564 if (!isOpen) {
565 this._openedVia = null;
566 }
567
568 return result;
569 }
570
571 /**
572 * 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