Combobox with footer on the menu #977
-
Hi team, We are using paste Combobox which displays a list of options fetched from the backend for the search query on the Combobox. We have an use-case to display only finite amount of options (say 20) on the combobox options and if there are still more results available for the backend, we are trying to show a footer message that advices the user to type more for more accurate matches. CodeSandbox:- https://codesandbox.io/s/combobox-with-footer-in-the-menu-forked-lkoy9?file=/src/index.tsx I have used the The idea is to use an empty Q1) Is there a way to prevent the last empty footer option from rendering and just the label to be visible? Or is there any other ways of adding footer to the combobox menu? Q2) Is there a way to specify the maxHeight for the Combobox menu? Currently the |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
Hi @balajimuthusubash, thanks for your question. Unfortunately there is no concept of a footer in a Combobox at the moment. The only thing we can support accessibly is that everything you see in a combobox is an option, so that a user can navigate to it using their keyboard (if you use your up and down arrow keys you can navigate the list and make a selection). If it's not a valid option, a user won't be able to perceive that information. So the reason it's trying to render an empty option, is that it expects you to pass it one. It can't be An easy way round this would be to manually append your instructional option to the data and give it some identifier in the JSON. Then use the |
Beta Was this translation helpful? Give feedback.
-
Thanks Simon for the quick response. Can you also let me know if there are ways to restrict the max-height of the Combobox menu and enforce scroll through some params to the Combobox? One way I could think of achieving this is by overriding the max-height set from the Paste on the Combobox menu in CSS?
|
Beta Was this translation helpful? Give feedback.
Hi @balajimuthusubash, thanks for your question.
Unfortunately there is no concept of a footer in a Combobox at the moment. The only thing we can support accessibly is that everything you see in a combobox is an option, so that a user can navigate to it using their keyboard (if you use your up and down arrow keys you can navigate the list and make a selection).
If it's not a valid option, a user won't be able to perceive that information.
So the reason it's trying to render an empty option, is that it expects you to pass it one. It can't be
null
.An easy way round this would be to manually append your instructional option to the data and give it some identifier in the JSON. Then use the
o…