This commit is contained in:
Vanessa 2023-11-10 20:01:31 +08:00
parent 2d99bf6a8f
commit 580a502714
2 changed files with 42 additions and 17 deletions

View file

@ -82,9 +82,15 @@ export const commandPanel = (app: App) => {
const filterList = (inputElement: HTMLInputElement, listElement: Element) => {
const inputValue = inputElement.value.toLowerCase();
listElement.querySelector(".b3-list-item--focus")?.classList.remove("b3-list-item--focus");
let hasFocus = false;
Array.from(listElement.children).forEach((element: HTMLElement) => {
const elementValue = element.querySelector(".b3-list-item__text").textContent.toLowerCase();
if (inputValue.indexOf(elementValue) > -1 || elementValue.indexOf(inputValue) > -1) {
if (!hasFocus) {
element.classList.add("b3-list-item--focus");
}
hasFocus = true
element.classList.remove("fn__none");
} else {
element.classList.add("fn__none");