Skip to content

Commit

Permalink
Hide the terms filter box if there are fewer than 8 terms (#10438)
Browse files Browse the repository at this point in the history
  • Loading branch information
notnownikki authored Oct 9, 2018
1 parent 471e581 commit b869b99
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ const DEFAULT_QUERY = {
_fields: 'id,name,parent',
};

const MIN_TERMS_COUNT_FOR_FILTER = 8;

class HierarchicalTermSelector extends Component {
constructor() {
super( ...arguments );
Expand Down Expand Up @@ -384,14 +386,15 @@ class HierarchicalTermSelector extends Component {
slug === 'category' ? __( 'Categories' ) : __( 'Terms' )
)
);
const showFilter = availableTerms.length >= MIN_TERMS_COUNT_FOR_FILTER;

return [
<label
showFilter && <label
key="filter-label"
htmlFor={ filterInputId }>
{ filterLabel }
</label>,
<input
showFilter && <input
type="search"
id={ filterInputId }
value={ filterValue }
Expand Down

0 comments on commit b869b99

Please sign in to comment.