Skip to content

Commit

Permalink
refactor: move text filter event handler to text filter generation me…
Browse files Browse the repository at this point in the history
…thod
  • Loading branch information
0x4007 committed Jan 23, 2024
1 parent f66d81b commit 03c1e79
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
11 changes: 0 additions & 11 deletions src/home/rendering/setup-keyboard-navigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
13 changes: 12 additions & 1 deletion src/home/sorting/sorting-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -43,7 +55,6 @@ export class SortingManager {
});

return buttons;
// this._filters.appendChild(labels);
}

private _createRadioButton(option: string): HTMLInputElement {
Expand Down
1 change: 0 additions & 1 deletion static/style/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,6 @@
display: inline-flex;
text-align: left;
margin: 0 16px;
cursor: pointer;
}
#authenticated > * {
display: inline-flex;
Expand Down

0 comments on commit 03c1e79

Please sign in to comment.