Combobox, Menu, ContextMenu, and Command each need to know how many items match the search. They use the count to show the empty state and to announce "N results" for screen readers.
Base UI's own count (useFilteredItems) only works when the root gets an items prop. Our components also filter their own children, so they need their own count.
Today there are two ways to do this:
Both do the same job.
Proposal
After #953, #954, and #960 merge, move Combobox to shared/item-count and delete its own count. Keep one code path for the empty state and the status message in all four components.
Select's search mode (#958) only shows Select.Empty when items is given. It could use the same helper to work without items too.
Combobox, Menu, ContextMenu, and Command each need to know how many items match the search. They use the count to show the empty state and to announce "N results" for screen readers.
Base UI's own count (
useFilteredItems) only works when the root gets anitemsprop. Our components also filter their own children, so they need their own count.Today there are two ways to do this:
packages/react/shared/item-count/. Each item adds itself to the count while it is shown. Menu, ContextMenu, and Command use it.Both do the same job.
Proposal
After #953, #954, and #960 merge, move Combobox to
shared/item-countand delete its own count. Keep one code path for the empty state and the status message in all four components.Select's search mode (#958) only shows
Select.Emptywhenitemsis given. It could use the same helper to work withoutitemstoo.