Skip to content

Commit

Permalink
On template creation, don't show search if not needed (#42357)
Browse files Browse the repository at this point in the history
* On template creation, don't show search if not needed

* use useState
  • Loading branch information
ntsekouras authored Jul 13, 2022
1 parent 72062fc commit d706005
Showing 1 changed file with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -145,14 +145,20 @@ function SuggestionList( { entityForSuggestions, onSelect } ) {
debouncedSearch
);
const { labels } = entityForSuggestions;
const [ showSearchControl, setShowSearchControl ] = useState( false );
if ( ! showSearchControl && suggestions?.length > 9 ) {
setShowSearchControl( true );
}
return (
<>
<SearchControl
onChange={ setSearch }
value={ search }
label={ labels.search_items }
placeholder={ labels.search_items }
/>
{ showSearchControl && (
<SearchControl
onChange={ setSearch }
value={ search }
label={ labels.search_items }
placeholder={ labels.search_items }
/>
) }
{ !! suggestions?.length && (
<Composite
{ ...composite }
Expand Down

0 comments on commit d706005

Please sign in to comment.