From 39e644d533dcaf008eb80f5f41824deae782d554 Mon Sep 17 00:00:00 2001 From: Mohd Ashraf <57627350+mohdashraf010897@users.noreply.github.com> Date: Wed, 15 Mar 2023 22:31:04 +0530 Subject: [PATCH] feat(web): v3 support select type featured suggestion (#2198) * feat(web): handle select type featured suggestions * feat(web): call onValueSelected callback on select type suggestion selection * revert example file --- .../web/src/components/search/SearchBox.js | 24 ++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/packages/web/src/components/search/SearchBox.js b/packages/web/src/components/search/SearchBox.js index 4ea1e86b60..e021eab2f9 100644 --- a/packages/web/src/components/search/SearchBox.js +++ b/packages/web/src/components/search/SearchBox.js @@ -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 @@ -1767,14 +1776,13 @@ const ForwardRefComponent = React.forwardRef((props, ref) => ( componentType={componentTypes.searchBox} mode={preferenceProps.testMode ? 'test' : ''} > - { - componentProps => - () - } + {componentProps => ( + + )} )}