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