1
0
mirror of https://github.com/flarum/core.git synced 2025-07-26 03:01:22 +02:00

Switch to constructor MIN_SEARCH_LENGTH in Search component (#3130)

This commit is contained in:
David Sevilla Martin
2021-10-30 19:13:43 -04:00
committed by GitHub
parent 574ba355c2
commit 26e44f47ca

View File

@@ -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;
@@ -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;