If I click outside of Material UI Autocomplete input field then all text of input field got vanished

Viewed 1599

I'm using Material Ui Autocomplete component. So if you write something on that box and then click anywhere outside that input field your input field texts just got cleared out.How can I solve this problem?

import React from 'react';
import TextField from '@material-ui/core/TextField';
import Autocomplete, { createFilterOptions } from '@material-ui/lab/Autocomplete';

export default function Filter() {
  return (
    <Autocomplete
      id="filter-demo"
      options={top100Films}
      getOptionLabel={(option) => option.title}
      filterOptions={x => x}
      style={{ width: 300 }}
      renderInput={(params) => <TextField {...params} label="Custom filter" variant="outlined" />}
    />
  );
}

watch the included image for better understanding

1 Answers

Just able to solve the problem I was facing. Just adding clearOnBlur={false} prop inside Autocomplete Component do the job.

Related