diff --git a/assets/pages/Index.vue b/assets/pages/Index.vue index 24b17922703..26777792a77 100644 --- a/assets/pages/Index.vue +++ b/assets/pages/Index.vue @@ -74,6 +74,7 @@ import { mapActions, mapGetters, mapState } from "vuex"; import Icon from "../components/Icon"; import PastTime from "../components/PastTime"; import config from "../store/config"; +import fuzzysort from "fuzzysort"; export default { name: "Index", @@ -107,7 +108,7 @@ export default { results() { if (this.search) { const term = this.search.toLowerCase(); - return this.allContainers.filter((c) => c.name.toLowerCase().includes(term)); + return fuzzysort.go(term, this.allContainers, { key: "name" }).map((i) => i.obj); } switch (this.sort) { case "all": diff --git a/package.json b/package.json index fbb6eb00ae2..b489c397c69 100644 --- a/package.json +++ b/package.json @@ -32,6 +32,7 @@ "bulma": "^0.9.2", "date-fns": "^2.19.0", "dompurify": "^2.2.7", + "fuzzysort": "^1.1.4", "hotkeys-js": "^3.8.3", "lodash.debounce": "^4.0.8", "lodash.throttle": "^4.1.1", diff --git a/yarn.lock b/yarn.lock index d992ff52882..13d380c5076 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4029,6 +4029,11 @@ function-bind@^1.1.1: resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.1.tgz#a56899d3ea3c9bab874bb9773b7c5ede92f4895d" integrity sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A== +fuzzysort@^1.1.4: + version "1.1.4" + resolved "https://registry.yarnpkg.com/fuzzysort/-/fuzzysort-1.1.4.tgz#a0510206ed44532cbb52cf797bf5a3cb12acd4ba" + integrity sha512-JzK/lHjVZ6joAg3OnCjylwYXYVjRiwTY6Yb25LvfpJHK8bjisfnZJ5bY8aVWwTwCXgxPNgLAtmHL+Hs5q1ddLQ== + gensync@^1.0.0-beta.2: version "1.0.0-beta.2" resolved "https://registry.yarnpkg.com/gensync/-/gensync-1.0.0-beta.2.tgz#32a6ee76c3d7f52d46b2b1ae5d93fea8580a25e0"