* 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)
| 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. |
no test coverage detected