Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

200
Vistas
Matrial-UI <Autocomplete /> search by multiple parameters

So i've started learning Material UI and i have a question.

We have an object

const top100Films = [
  { label: 'The Shawshank Redemption', year: 1994 },
  { label: 'The Godfather', year: 1972 }, 

  * ...More items *
]

Right now if i set getOptionLabel = {option => option.label} in my Autocomplete it will only search by matching label(title) so if i enter a year i.e "1994" it won't show "The Shawshank Redemption" in my search results, and if i set it to option.year it will only search by year and any input but year will be invalid.

Here's my question: Is there a way to set it so i can search both by title or by year.

Solution:

<Autocomplete
  ...
  filterOptions={(options, { inputValue }) => options.filter(item => item.label.toLowerCase().includes(inputValue) || item.year.toString().includes(inputValue) )}
/>
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

MUI Autocomplete API has filterOptions (docs here) prop where you can set custom filtering.

I would implement it something like:

<Autocomplete
  ...
  filterOptions={(options, { inputValue }) => options.filter(item => item.label.includes(inputValue) || item.year.toString.includes(inputValue) )}
/>
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda