Do not show typeahead unless there is more than one item in the listbox

This commit is contained in:
Tom Southall
2022-03-11 21:05:51 +00:00
parent ae48c619c4
commit 9c98b30e16
4 changed files with 7 additions and 25 deletions

View File

@@ -78,6 +78,8 @@ export default function Container(props) {
const typeaheadInput = useRef(null)
// Calculated states
console.log('hasTypeahead', typeahead, state.items.length > 1)
const hasTypeahead = typeahead && state.items.length > 1
const hasClearButton = clearButton && !!state.query
const hasCancelButton = cancelButton && hasFocus
const isExpanded = hasFocus && state.itemsLoaded
@@ -241,7 +243,7 @@ export default function Container(props) {
aria-controls={listboxId}
/>
{typeahead && (
{hasTypeahead && (
<input
className={`${inputStyles || ''} ${customStyles.typeahead || ''}`.trim()}
style={defaultStyles.typeahead}