Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

136
Views
MUI Autocompletar filterOptioms sigue mostrando todas las opciones

Hola a todos,

Un poco raro ahora. Tengo un Autocompletar muy personalizado debido a restricciones y otros casos de uso. Ahora tengo un problema con el filtro. Sigue mostrando todas las opciones disponibles. Console.registré el resultado del filtro en sí mismo y esto funciona correctamente. Cuando lo registro solo veo los valores filtrados. La cosa es que todas las opciones permanecen mostradas. Ninguno está filtrado.

En breve;

  • Cuando registro el resultado de filterOptions, es correcto. Por ejemplo, busco "Países Bajos", solo muestra el resultado relevante. options.filter() hace bien su trabajo.
  • Estos resultados no se muestran. Autocompletar todavía muestra todos los valores.

¿Qué está yendo mal aquí? ¿Manejo algo mal o hay algo más en juego?

 <Autocomplete options={allCountries} onChange={(event, newValue) => { if (!newValue || !newValue[1] || !newValue[1].phone) return; setPrefix(newValue[1].phone); }} value={allCountries.find( (nestedArray) => nestedArray[1].phone === prefix )} autoHighlight getOptionLabel={(option) => `+${option[1].phone}`} renderOption={(props, option) => ( <Box component="li" sx={{ "& > img": { mr: 2, flexShrink: 0 } }} {...props} > <img width="20" src={`https://flagcdn.com/w20/${option[0].toLowerCase()}.png`} /> {option[1].name} (+{option[1].phone}) </Box> )} filterOptions={(options, state) => { if (state.inputValue === "") return options; const query = state.inputValue.toLowerCase(); return options.filter((option) => { return `${option[1].name.toLowerCase()} (+${ option[1].phone })`.includes(query); }); }} renderInput={(params) => ( <TextField {...params} label="Prefix" inputProps={{ ...params.inputProps, }} /> )} />
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Por lo que puedo ver, está actualizando solo la propiedad de value después de que se haya cambiado el prefijo. Pero, además de eso, también debe actualizar la propiedad inputValue , que es responsable del valor que se muestra en el cuadro de texto:

 const [inputValue, setInputValue] = React.useState(''); ... inputValue={inputValue} onInputChange={(event, newInputValue) => { setInputValue(newInputValue); }} ...
about 4 years ago · Juan Pablo Isaza Report

0

const [allCountries, setAllCountries] = useState([ //initial Options ]); const onChange= (inputValue )=>{ if (inputValue === "") return options; const query = inputValue.toLowerCase(); let list = options.filter((option) => { return `${option[1].name.toLowerCase()} (+${ option[1].phone })`.includes(query); }); setAllCountries(state=>(list)) }

accesorios de autocompletar:

 onChange={(e, value) => onChange(value)}
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!