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

267
Views
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 answers
Answer question

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 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!