Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow extensions to modify MIN_SEARCH_LENGTH in Search component #3130

Merged
merged 1 commit into from
Oct 30, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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