(focusStrategy: FocusStrategy | null = null, trigger?: MenuTriggerAction)
| 324 | defaultOpen: undefined |
| 325 | }); |
| 326 | let open = (focusStrategy: FocusStrategy | null = null, trigger?: MenuTriggerAction) => { |
| 327 | let displayAllItems = trigger === 'manual' || (trigger === 'focus' && menuTrigger === 'focus'); |
| 328 | // Prevent open operations from triggering if there is nothing to display |
| 329 | // Also prevent open operations from triggering if items are uncontrolled but defaultItems is empty, even if displayAllItems is true. |
| 330 | // This is to prevent comboboxes with empty defaultItems from opening but allow controlled items comboboxes to open even if the inital list is empty (assumption is user will provide swap the empty list with a base list via onOpenChange returning `menuTrigger` manual) |
| 331 | if ( |
| 332 | allowsEmptyCollection || |
| 333 | filteredCollection.size > 0 || |
| 334 | (displayAllItems && originalCollection.size > 0) || |
| 335 | props.items |
| 336 | ) { |
| 337 | if (displayAllItems && !triggerState.isOpen && props.items === undefined) { |
| 338 | // Show all items if menu is manually opened. Only care about this if items are undefined |
| 339 | setShowAllItems(true); |
| 340 | } |
| 341 | |
| 342 | menuOpenTrigger.current = trigger; |
| 343 | setFocusStrategy(focusStrategy); |
| 344 | triggerState.open(); |
| 345 | } |
| 346 | }; |
| 347 | |
| 348 | let toggle = (focusStrategy: FocusStrategy | null = null, trigger?: MenuTriggerAction) => { |
| 349 | let displayAllItems = trigger === 'manual' || (trigger === 'focus' && menuTrigger === 'focus'); |
no test coverage detected