Skip to content
This repository has been archived by the owner on Jul 24, 2024. It is now read-only.

Commit

Permalink
feat(search): add searchOnEnter flag to SearchBox, default true
Browse files Browse the repository at this point in the history
  • Loading branch information
LoneRifle committed Sep 2, 2021
1 parent 4cf6889 commit dd9a001
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ export const EnquiryModal = ({
placeholder=""
value=""
showSearchIcon={false}
searchOnEnter={false}
isInvalid={formErrors.questionTitle}
inputRef={ref}
{...questionTitleProps}
Expand Down
7 changes: 5 additions & 2 deletions client/src/components/SearchBox/SearchBox.component.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const SearchBox = ({
inputRef,
handleSubmit = undefined,
handleAbandon = (_inputValue) => {},
searchOnEnter = true,
showSearchIcon = true,
...inputProps
}) => {
Expand Down Expand Up @@ -146,9 +147,11 @@ const SearchBox = ({
// when selecting option using keyboard
// downshift prevents form submission which is used to submit analytics event
// detect such event and separately send analytics event
sendSearchEventToAnalytics(inputValue)
if (highlightedIndex === null) {
if (highlightedIndex === null && searchOnEnter) {
sendSearchEventToAnalytics(inputValue)
handleSubmit(inputValue)
} else if (highlightedIndex !== null) {
sendSearchEventToAnalytics(inputValue)
}
}

Expand Down

0 comments on commit dd9a001

Please sign in to comment.