Skip to content

Commit

Permalink
feat(web): v3 support select type featured suggestion (#2198)
Browse files Browse the repository at this point in the history
* feat(web): handle select type featured suggestions

* feat(web): call onValueSelected callback on select type suggestion selection

* revert example file
  • Loading branch information
mohdashraf010897 authored Mar 15, 2023
1 parent fb274f3 commit 39e644d
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions packages/web/src/components/search/SearchBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,15 @@ const SearchBox = (props) => {
const func = new Function(`return ${suggestion.subAction}`)();
func(suggestion, currentValue, customEvents);
}
if (suggestion.action === featuredSuggestionsActionTypes.SELECT) {
setValue(
suggestion.value,
true,
props,
isTagsMode.current ? causes.SUGGESTION_SELECT : causes.ENTER_PRESS,
);
onValueSelected(suggestion.value, causes.SUGGESTION_SELECT);
}
// blur is important to close the dropdown
// on selecting one of featured suggestions
// else Downshift probably is focusing the dropdown
Expand Down Expand Up @@ -1767,14 +1776,13 @@ const ForwardRefComponent = React.forwardRef((props, ref) => (
componentType={componentTypes.searchBox}
mode={preferenceProps.testMode ? 'test' : ''}
>
{
componentProps =>
(<ConnectedComponent
{...preferenceProps}
{...componentProps}
myForwardedRef={ref}
/>)
}
{componentProps => (
<ConnectedComponent
{...preferenceProps}
{...componentProps}
myForwardedRef={ref}
/>
)}
</ComponentWrapper>
)}
</PreferencesConsumer>
Expand Down

0 comments on commit 39e644d

Please sign in to comment.