Flushes any pending focus when the menu instance becomes available.
()
| 681 | |
| 682 | /** Flushes any pending focus when the menu instance becomes available. */ |
| 683 | pendingFocusEffect(): void { |
| 684 | const menu = this.inputs.menu(); |
| 685 | const intent = this.pendingFocus(); |
| 686 | const items = menu?.items(); |
| 687 | |
| 688 | // We check the items so that we don't try calling into |
| 689 | // `first/last` until the items are actually available. |
| 690 | if (menu && intent && items?.length) { |
| 691 | if (intent === 'first') { |
| 692 | menu.first(); |
| 693 | } else if (intent === 'last') { |
| 694 | menu.last(); |
| 695 | } |
| 696 | this.pendingFocus.set(undefined); |
| 697 | } |
| 698 | } |
| 699 | |
| 700 | /** Handles keyboard events for the menu trigger. */ |
| 701 | onKeydown(event: KeyboardEvent) { |