From 03c1e795656453e32746f7dc803a5d7e04c9095c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=A2=E3=83=AC=E3=82=AF=E3=82=B5=E3=83=B3=E3=83=80?= =?UTF-8?q?=E3=83=BC=2Eeth?= Date: Tue, 23 Jan 2024 19:01:57 +0900 Subject: [PATCH] refactor: move text filter event handler to text filter generation method --- src/home/rendering/setup-keyboard-navigation.ts | 11 ----------- src/home/sorting/sorting-manager.ts | 13 ++++++++++++- static/style/style.css | 1 - 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/home/rendering/setup-keyboard-navigation.ts b/src/home/rendering/setup-keyboard-navigation.ts index e186ba4b..a7bc65db 100644 --- a/src/home/rendering/setup-keyboard-navigation.ts +++ b/src/home/rendering/setup-keyboard-navigation.ts @@ -16,17 +16,6 @@ export function setupKeyboardNavigation(container: HTMLDivElement) { container.addEventListener("mouseover", () => disableKeyBoardNavigationCurried); isMouseOverListenerAdded = true; } - - const filterTextbox = document.getElementById("filter") as HTMLInputElement; - filterTextbox.addEventListener("input", () => { - const filterText = filterTextbox.value.toLowerCase(); - const issues = Array.from(container.children) as HTMLDivElement[]; - issues.forEach((issue) => { - const issueText = issue.textContent?.toLowerCase() || ""; - const isVisible = issueText.includes(filterText); - issue.style.display = isVisible ? "block" : "none"; - }); - }); } function disableKeyboardNavigationCurry() { diff --git a/src/home/sorting/sorting-manager.ts b/src/home/sorting/sorting-manager.ts index 271e6103..ae065d09 100644 --- a/src/home/sorting/sorting-manager.ts +++ b/src/home/sorting/sorting-manager.ts @@ -25,6 +25,18 @@ export class SortingManager { textBox.type = "text"; textBox.id = "filter"; textBox.placeholder = "Text Filter"; + + const issuesContainer = document.getElementById("issues-container") as HTMLDivElement; + textBox.addEventListener("input", () => { + const filterText = textBox.value.toLowerCase(); + const issues = Array.from(issuesContainer.children) as HTMLDivElement[]; + issues.forEach((issue) => { + const issueText = issue.textContent?.toLowerCase() || ""; + const isVisible = issueText.includes(filterText); + issue.style.display = isVisible ? "block" : "none"; + }); + }); + return textBox; } @@ -43,7 +55,6 @@ export class SortingManager { }); return buttons; - // this._filters.appendChild(labels); } private _createRadioButton(option: string): HTMLInputElement { diff --git a/static/style/style.css b/static/style/style.css index 5926b66f..fdefd5bf 100644 --- a/static/style/style.css +++ b/static/style/style.css @@ -282,7 +282,6 @@ display: inline-flex; text-align: left; margin: 0 16px; - cursor: pointer; } #authenticated > * { display: inline-flex;