I have a Material UI autoplete that selects its items based on the 3 letters you type, for example:
You want to fetch all the Pedros in your database, then you type "Ped" and it brings you only results that start with "Ped".
The problem is when I click in the auto plete it immediately shows the message "No options" like
And I want it only to show after I typed 3 characters and it did not find any "Ped" in the database like:
I tried to put a condition inside the prop "noOptionsText" but it did not work. Does anyone know how to do it?
EDIT: Without using freeSolo, the option needs to be an object
I have a Material UI autoplete that selects its items based on the 3 letters you type, for example:
You want to fetch all the Pedros in your database, then you type "Ped" and it brings you only results that start with "Ped".
The problem is when I click in the auto plete it immediately shows the message "No options" like
And I want it only to show after I typed 3 characters and it did not find any "Ped" in the database like:
I tried to put a condition inside the prop "noOptionsText" but it did not work. Does anyone know how to do it?
EDIT: Without using freeSolo, the option needs to be an object
Share Improve this question edited Mar 24, 2020 at 15:22 keikai 15.2k10 gold badges55 silver badges72 bronze badges asked Mar 24, 2020 at 14:17 Pedro W. BotelhoPedro W. Botelho 2841 gold badge4 silver badges14 bronze badges1 Answer
Reset to default 8Okay, I just found a way to answer my question.
There's the prop "open" in Material UI's Autoplete. I just put a condition like:
open={lenght >= 3}
Then it only opens the options when I've typed the first 3 characters, otherwise it won't open. Plus, when I typed the 3 characters and there's no options, it will display the no options text.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744404790a4572576.html
评论列表(0条)