Autocomplete does not filter a Tree
Provide a general summary of the feature here
Let Autocomplete filter a Tree, as it filters ListBox, Menu and GridList.
Expected Behavior?
Typing into an Autocomplete's SearchField filters the rows of a Tree inside it.
Current Behavior
The tree is not filtered. react-aria-components 1.21.1, Chromium, typing ban into each field of the example below:
typed 'ban': tree rows Apple/Banana/Cherry | listbox options BananaSelectableCollectionContext is read by Autocomplete.mjs, GridList.mjs, ListBox.mjs, Menu.mjs, Table.mjs and TagGroup.mjs under react-aria-components/dist/private/; Tree.mjs does not reference it.
Possible Solution
Have Tree consume SelectableCollectionContext as GridList does, filtering child rows and keeping the ancestors of a matching row.
Context
A searchable tree select in our design system. Today the caller has to filter the rows itself, while the listbox equivalent filters locally.
Examples
import { Autocomplete, Input, ListBox, ListBoxItem, SearchField, Tree, TreeItem, TreeItemContent, useFilter } from "react-aria-components";
export function Repro() {
const { contains } = useFilter({ sensitivity: "base" });
const fruits = ["Apple", "Banana", "Cherry"];
return (
<>
<Autocomplete filter={contains}>
<SearchField aria-label="tree search"><Input /></SearchField>
<Tree aria-label="tree">
{fruits.map((f) => <TreeItem key={f} id={f} textValue={f}><TreeItemContent>{f}</TreeItemContent></TreeItem>)}
</Tree>
</Autocomplete>
<Autocomplete filter={contains}>
<SearchField aria-label="list search"><Input /></SearchField>
<ListBox aria-label="list">{fruits.map((f) => <ListBoxItem key={f} id={f}>{f}</ListBoxItem>)}</ListBox>
</Autocomplete>
</>
);
}Your Company/Team
No response
Tracking Issue
No response
Source: adobe/react-spectrum