Material-ui: [AutoComplete] "openOnFocus" is defective

Created on 20 Apr 2017  路  5Comments  路  Source: mui-org/material-ui

Problem description

the prop "openOnFocus" from the AutoComplete Component doesn't function as desired because the filter function doesn't take in consideration the prop.

filter: (searchText, key) => searchText !== '' && key.indexOf(searchText) !== -1,

so when the prop is true nothing really happens because the searchText == ""

Link to minimal working code that reproduces the issue

<AutoComplete openOnFocus hintText="Type anything" dataSource={ [ "exeption1","other Type", "another Type" ]} onUpdateInput={this.handleUpdateInput} />

Versions

  • Material-UI: 17.4
  • React: 15.5
  • Browser:
Autocomplete

Most helpful comment

So perhaps the solution would be to override the default filter with (searchText, key) => (key.indexOf(searchText) !== -1) if openOnFocus is true and no filter is provided.

All 5 comments

+1

Can't you just set filter={(searchText, key) => (key.indexOf(searchText) !== -1)} to get the functionality you're looking for?

Yea that is what I did on my end. However, if someone downloads the library and tries the prop "openOnFocus" it will not work.

So perhaps the solution would be to override the default filter with (searchText, key) => (key.indexOf(searchText) !== -1) if openOnFocus is true and no filter is provided.

Closed by #4783

Was this page helpful?
0 / 5 - 0 ratings