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> = { const options: IFuseOptions<StoreAddon> = {
keys: ["name", "description", "slug"], keys: ["name", "description", "slug"],
isCaseSensitive: false, isCaseSensitive: false,
minMatchCharLength: 2, minMatchCharLength: Math.min(filter.length, 2),
threshold: 0.2, threshold: 0.2,
}; };
const fuse = new Fuse(addons, options); const fuse = new Fuse(addons, options);

View File

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

View File

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

View File

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