Skip to content

Commit

Permalink
Don't fire onSelected when Clear button is clicked
Browse files Browse the repository at this point in the history
  • Loading branch information
runely committed Aug 24, 2022
1 parent 756daca commit 163ee2b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/ui/SearchField/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ export function SearchField ({ placeholder, value, debounceMs, onSelected, round

// Handles clicking the searchResult items
const handleItemClick = (item, index) => {
if (onSelected && typeof onSelected === 'function') onSelected(item, index)
if (onSelected && typeof onSelected === 'function' && item !== undefined && index !== undefined) onSelected(item, index)

// Set the index of the selected item
if (index !== undefined && index >= 0 && index < items.length) setFocusedItemIndex(index)
Expand Down

1 comment on commit 163ee2b

@vercel
Copy link

@vercel vercel bot commented on 163ee2b Aug 24, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.