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

262
Vistas
React Material UI Autocomplete get uncompleted user input

I'm using Material UI's Autocomplete input with react-hook-form like this:

import React from "react";
import {Controller} from "react-hook-form";
import {Autocomplete} from "@mui/material";

export const ControlledAutocomplete = ({
                                           options,
                                           renderInput,
                                           getOptionLabel,
                                           onChange: ignored,
                                           control,
                                           defaultValue,
                                           name,
                                           renderOption,
                                           viewOnly
                                       }) => {
    return (
        <Controller
            defaultValue={defaultValue}
            render={({field: {onChange, ...props}, fieldState: {error}}) => (
                <Autocomplete
                    options={options || []}
                    getOptionLabel={getOptionLabel}
                    isOptionEqualToValue={(option, value) => {
                        if (typeof (value) === 'object') {
                            return option.id === value.id
                        } else {
                            return option.id === value
                        }
                    }}
                    renderOption={renderOption}
                    disabled={viewOnly}
                    autoComplete={true}
                    renderInput={renderInput}
                    onChange={(e, data) => onChange(data)}
                    {...props}
                />
            )}
            control={control}
            name={name}
        />
    );
}

This works great, but I want to get the user input if no suggestion is available. Basically if there is no suggestion from the autocomplete list, I want to get the raw input from user. Is it somehow possible with Autocomplete or with any other input field in MUI?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

It seems that I was looking for the freeSolo setting:

Autocomplete with custom input in material ui not working

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