Flushes any pending focus when the menu instance becomes available.
()
| 713 | |
| 714 | /** Flushes any pending focus when the menu instance becomes available. */ |
| 715 | pendingFocusEffect(): void { |
| 716 | const menu = this.inputs.menu(); |
| 717 | const intent = this.pendingFocus(); |
| 718 | const items = menu?.items(); |
| 719 | |
| 720 | // We check the items so that we don't try calling into |
| 721 | // `first/last` until the items are actually available. |
| 722 | if (menu && intent && items?.length) { |
| 723 | if (intent === 'first') { |
| 724 | menu.first(); |
| 725 | } else if (intent === 'last') { |
| 726 | menu.last(); |
| 727 | } |
| 728 | this.pendingFocus.set(undefined); |
| 729 | } |
| 730 | } |
| 731 | |
| 732 | /** Handles keyboard events for the menu trigger. */ |
| 733 | onKeydown(event: KeyboardEvent) { |