Improve search for single character (#18748)

This commit is contained in:
Paul Bottein 2023-11-24 15:37:59 +01:00 committed by GitHub
parent 15b1d8ee14
commit 3da7025d78
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 5 additions and 5 deletions

View File

@ -6,7 +6,7 @@ export function filterAndSort(addons: StoreAddon[], filter: string) {
const options: IFuseOptions<StoreAddon> = {
keys: ["name", "description", "slug"],
isCaseSensitive: false,
minMatchCharLength: 2,
minMatchCharLength: Math.min(filter.length, 2),
threshold: 0.2,
};
const fuse = new Fuse(addons, options);

View File

@ -249,7 +249,7 @@ class AddIntegrationDialog extends LitElement {
"iot_standards",
],
isCaseSensitive: false,
minMatchCharLength: 2,
minMatchCharLength: Math.min(filter.length, 2),
threshold: 0.2,
};
const helpers = Object.entries(h).map(([domain, integration]) => ({

View File

@ -161,7 +161,7 @@ class HaConfigIntegrationsDashboard extends SubscribeMixin(LitElement) {
const options: IFuseOptions<ConfigEntryExtended> = {
keys: ["domain", "localized_domain_name", "title"],
isCaseSensitive: false,
minMatchCharLength: 2,
minMatchCharLength: Math.min(filter.length, 2),
threshold: 0.2,
};
const fuse = new Fuse(configEntries, options);
@ -205,7 +205,7 @@ class HaConfigIntegrationsDashboard extends SubscribeMixin(LitElement) {
const options: IFuseOptions<DataEntryFlowProgressExtended> = {
keys: ["handler", "localized_title"],
isCaseSensitive: false,
minMatchCharLength: 2,
minMatchCharLength: Math.min(filter.length, 2),
threshold: 0.2,
};
const fuse = new Fuse(configEntriesInProgress, options);

View File

@ -81,7 +81,7 @@ export class HuiCardPicker extends LitElement {
const options: IFuseOptions<Card> = {
keys: ["type", "name", "description"],
isCaseSensitive: false,
minMatchCharLength: filter.length === 1 ? 1 : 2,
minMatchCharLength: Math.min(filter.length, 2),
threshold: 0.2,
};
const fuse = new Fuse(cards, options);