Autocomplete does not filter a Tree

Aperta
#10,664 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
78/100
Tipo di issue
Funzionalità
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
react, typescript
Ambito
frontend

Direzione di ricerca

Start by comparing Tree.mjs with GridList.mjs and the other components that consume SelectableCollectionContext under react-aria-components/dist/private/. Verify the existing Autocomplete example with ListBox, then make the tree filter matching rows while retaining their ancestors; the reproduced tree and list behavior should agree when typing “ban”.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Autocomplete
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 Banana

SelectableCollectionContext 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

Lingua principale
TypeScript
Stelle
16k
Fork
1.6k
Merge medio
3g 19h
PR unite (30g)
46

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di adobe/react-spectrum

Tutte le issue di adobe/react-spectrum

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.