TeamSearchField: filterSelectedOptions filters MUI's internal value, not the actual selection
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
- 68/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- react, typescript
- Ambito
- frontend
Direzione di ricerca
Inizia in TeamSearchField tracciando teamsData, handleAdd, filterSelectedOptions, isOptionEqualToValue e le chiamate a fetchSuggestions. Confronta i due approcci suggeriti e controlla i picker fratelli di InviteUserModal per individuare lo stesso pattern. Il lavoro è completo quando ogni team selezionato rimane nascosto dopo i refetch, i confronti restano corretti con oggetti option sostituiti e il controllo dei duplicati esistente continua a funzionare.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Summary
TeamSearchField keeps its real selection in parent state (teamsData) while leaving the MUI Autocomplete uncontrolled, and then relies on the Autocomplete's internal value for filterSelectedOptions. The two disagree, so the filtering is partial and does not survive a refetch.
Not a regression - it is the shape the component is left in after layer5io/sistent#1780 removed a value={inputValue} prop that bound a string to an object-valued Autocomplete. That prop was a type error masked by a file-level @ts-nocheck; removing the suppression forced it out and switched the component from (broken) controlled to uncontrolled, which is what made filterSelectedOptions start working at all. Keeping the now-live filter was a deliberate call - it restores what the author evidently intended and the UX is better. This issue is about finishing the job properly.
The mismatch
Three facts that do not compose:
- The Autocomplete is single-select and uncontrolled. There is no
multipleand novalue. MUI's internal value is therefore the last selected option, not the selection set. - The real selection set lives in the parent, as
teamsData, appended byhandleAddand rendered as Chips outside the Autocomplete. filterSelectedOptionsfilters against fact 1, not fact 2. So at most one team - whichever was picked most recently - is hidden from the dropdown. Every other already-selected team stays listed.
On top of that, isOptionEqualToValue={(option, value) => option === value} is reference equality, and options is replaced wholesale on every fetchSuggestions(...) call (onInputChange, and the useEffect on mount / orgID change). After any refetch the retained value is no longer reference-equal to the new option objects, so even that single team reappears.
Net: the filter applies to one team, sometimes, until the next keystroke. What actually prevents a duplicate selection is the explicit guard in handleAdd, which sets the "Team Already Selected" error.
Why fix it
The component currently works by accident on two levels - correctness is carried by the handleAdd duplicate guard, while the visible filtering is incidental. Anyone who later needs to control the field programmatically (clear it after a successful invite, preselect teams when editing) will reach for value and land straight back on the bug that @ts-nocheck was hiding.
Suggested resolution
Either of these, not both:
- Derive the filter from the real selection. Drop
filterSelectedOptionsand filteroptionsagainstteamsDatadirectly, so every selected team is hidden, deterministically, regardless of refetches. Smallest change, keeps the component uncontrolled. - Make it properly controlled. Give the Autocomplete a correctly-typed object value (or
multiplewithvalue={teamsData}), which makesfilterSelectedOptionsmean what it says and makes programmatic control possible.
In either case replace the reference comparator with an id comparison - (option, value) => option.id === value.id - since options identities are not stable across fetches.
Worth checking InviteUserModal's sibling pickers for the same pattern while in here.
- Lingua principale
- TypeScript
- Stelle
- 137
- Fork
- 239
- Merge medio
- 4g 14h
- PR unite (30g)
- 5
Preparare l'ambiente
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di layer5io/sistent
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
I maintainer di solito rispondono entro 1 giorno
-
component/ui help wanted kind/enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
layer5io/sistent#1772 · 4 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
layer5io/sistent#1749 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
ESM build is not loadable by Node: extensionless 'lodash/debounce' specifier in dist/index.mjsAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
layer5io/sistent#1739 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
[Bug]: Catalog design card titles truncate to single line with no way to see full nameForse già presa @Maanvi212006 l’ha presa 5 giorni fa. Apertakind/bug
layer5io/sistent#1849 · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di layer5io/sistent
Issue simili
-
bug
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
StabilityNexus/Fate-EVM-Frontend#153 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
code-yeongyu/oh-my-openagent#9039 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
Tencent/teamai-cli#862 ·
I maintainer di solito rispondono entro 1 giorno
-
bug good first issue hacktoberfest redis
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
libredb/libredb-studio#1164 ·
I maintainer di solito rispondono entro 1 giorno
-
flake
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
I maintainer di solito rispondono entro 1 giorno