question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Enabling autocomplete filtering using multiple fields instead of just "getOptionLabel" field

See original GitHub issue

Currently using Autocomplete component of material UI, by default I can only filter options basing on “getOptionLabel” field. however, with “createFilterOptions” I can add another additional field like following.

const filterOptions = createFilterOptions({ matchFrom: 'start', stringify: option => option.title, });

I am wondering if I could be able to do something like below(should be able to filter with all the fields in the object)

const filterOptions = createFilterOptions({ matchFrom: 'start', stringify: option => option, });

Examples 🌈

here I am using match-sorter to include multiple fields(title and year) for filtering as per docs. can I achieve this without “match-sorter”? https://codesandbox.io/s/material-demo-urobl?file=/demo.js:618-632

Motivation 🔦

so that I don’t have to use another library to achieve this functionality.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:4
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
oliviertassinaricommented, Mar 18, 2021

@NMinhNguyen Ok, thanks for the explaination

1reaction
oliviertassinaricommented, Mar 18, 2021

@NMinhNguyen I think that we can delay the topic for some time, to better gauge the pain. createFilterOptions was meant to be a quick and dirty solution until developers implement something, on their side, that fully matches their use cases.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Material Autocomplete only filtering with getOptionLabel field
First, multi-additional-filter seems currently not supported by createFilterOptions . source of Material-UI Autocomplete createFilterOptions.
Read more >
A Guide on Material UI AutoComplete in React
This article will dive deep into the Material UI Autocomplete component, highlight its accompanied features and explore a potential use case in ...
Read more >
React Autocomplete component - Material UI
The autocomplete is a normal text input enhanced by a panel of suggested options. ... e.g., a location field must contain a valid...
Read more >
Select
The QSelect Vue component has two types of selection - single or multiple. This component opens up a menu for the selection list...
Read more >
Demystifying Errors in MUI Autocomplete — part
MUI: The `getOptionLabel` method of Autocomplete returned undefined instead of a string for “Andorra”. So the rule no:2 is simple — just ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found