Skip to content

Commit

Permalink
Tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
nmanu1 committed Nov 24, 2021
1 parent 6a2bee8 commit 8d540eb
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 19 deletions.
9 changes: 8 additions & 1 deletion sample-app/src/components/InputDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,11 @@ export default function InputDropdown({
}
dispatch({ type: 'FocusSection', newIndex: newSectionIndex });
} else if (focusedSectionIndex === numSections - 1 && !focusNext) {
dispatch({ type: 'FocusSection', newIndex: focusedSectionIndex - 1 });
let newSectionIndex: number | undefined = focusedSectionIndex - 1;
if (newSectionIndex < 0) {
newSectionIndex = undefined;
}
dispatch({ type: 'FocusSection', newIndex: newSectionIndex });
}
}

Expand Down Expand Up @@ -154,6 +158,9 @@ export default function InputDropdown({
}
}

console.log(numSections);
console.log(focusedSectionIndex);

return (
<>
<div className={cssClasses.inputContainer}>
Expand Down
39 changes: 21 additions & 18 deletions sample-app/src/components/SearchBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,24 +98,27 @@ export default function SearchBar({
inputContainer: 'SearchBar__inputContainer'
}}
>
<DropdownSection<Option>
options={options}
optionIdPrefix={`Autocomplete__option-${0}`}
onFocusChange={(value) => {
answersActions.setQuery(value);
}}
onClickOption={(option) => {
answersActions.setQuery(option.value);
executeQuery();
}}
cssClasses={{
sectionContainer: 'Autocomplete__dropdownSection',
sectionLabel: 'Autocomplete__sectionLabel',
optionsContainer: 'Autocomplete_sectionOptions',
option: 'Autocomplete__option',
focusedOption: 'Autocomplete__option--focused'
}}
/>
{
options.length > 0 &&
<DropdownSection<Option>
options={options}
optionIdPrefix={`Autocomplete__option-${0}`}
onFocusChange={(value) => {
answersActions.setQuery(value);
}}
onClickOption={(option) => {
answersActions.setQuery(option.value);
executeQuery();
}}
cssClasses={{
sectionContainer: 'Autocomplete__dropdownSection',
sectionLabel: 'Autocomplete__sectionLabel',
optionsContainer: 'Autocomplete_sectionOptions',
option: 'Autocomplete__option',
focusedOption: 'Autocomplete__option--focused'
}}
/>
}
</InputDropdown>
</div>
)
Expand Down

0 comments on commit 8d540eb

Please sign in to comment.