Skip to content

Commit

Permalink
feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
Yen Truong committed Oct 27, 2021
1 parent aaa27ba commit e95ebec
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
4 changes: 3 additions & 1 deletion sample-app/src/components/Dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ interface Props {
options: Option[],
onClickOption?: (option: Option) => void,
focusedOptionIndex: number | undefined,
optionIdPrefix: string,
cssClasses: {
optionContainer: string,
option: string,
Expand All @@ -23,6 +24,7 @@ export default function Dropdown({
options,
onClickOption = () => {},
focusedOptionIndex,
optionIdPrefix,
cssClasses
}: Props): JSX.Element | null {
function renderOption(option: Option, index: number) {
Expand All @@ -33,7 +35,7 @@ export default function Dropdown({
<div
key={index}
className={className}
id={`${cssClasses.option}-${index}`}
id={`${optionIdPrefix}-${index}`}
onClick={() => onClickOption(option)}>
{option.render()}
</div>)
Expand Down
5 changes: 4 additions & 1 deletion sample-app/src/components/InputDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ interface Props {
inputValue?: string,
placeholder?: string,
options: Option[],
optionIdPrefix: string,
onSubmit?: (value: string) => void,
updateInputValue: (value: string) => void,
updateDropdown: () => void,
Expand Down Expand Up @@ -46,6 +47,7 @@ export default function InputDropdown({
inputValue = '',
placeholder,
options,
optionIdPrefix,
onSubmit = () => {},
updateInputValue,
updateDropdown,
Expand All @@ -61,7 +63,7 @@ export default function InputDropdown({
});
const focusOptionId = focusedOptionIndex === undefined
? undefined
: `${cssClasses.option}-${focusedOptionIndex}`;
: `${optionIdPrefix}-${focusedOptionIndex}`;

const [latestUserInput, setLatestUserInput] = useState(inputValue);

Expand Down Expand Up @@ -134,6 +136,7 @@ export default function InputDropdown({
{shouldDisplayDropdown &&
<Dropdown
options={options}
optionIdPrefix={optionIdPrefix}
onClickOption={option => {
updateInputValue(option.value);
onSubmit(option.value)
Expand Down
1 change: 1 addition & 0 deletions sample-app/src/components/SearchBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export default function SearchBar({ placeholder, isVertical }: Props) {
render: () => renderWithHighlighting(result)
}
})}
optionIdPrefix='Autocomplete__option'
onSubmit={executeQuery}
updateInputValue={value => {
answersActions.setQuery(value);
Expand Down

0 comments on commit e95ebec

Please sign in to comment.