Skip to content

Commit

Permalink
Switch to constructor MIN_SEARCH_LENGTH in Search component (#3130)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsevillamartin authored Oct 30, 2021
1 parent 823c337 commit f260bd7
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions js/src/forum/components/Search.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ export interface SearchAttrs extends ComponentAttrs {
* - state: SearchState instance.
*/
export default class Search<T extends SearchAttrs = SearchAttrs> extends Component<T> {
static MIN_SEARCH_LEN = 3;
/**
* The minimum query length before sources are searched.
*/
protected static MIN_SEARCH_LEN = 3;

protected state!: SearchState;

Expand Down Expand Up @@ -211,7 +214,7 @@ export default class Search<T extends SearchAttrs = SearchAttrs> extends Compone
search.searchTimeout = setTimeout(() => {
if (state.isCached(query)) return;

if (query.length >= Search.MIN_SEARCH_LEN) {
if (query.length >= (search.constructor as typeof Search).MIN_SEARCH_LEN) {
search.sources.map((source) => {
if (!source.search) return;

Expand Down

0 comments on commit f260bd7

Please sign in to comment.