From 262e35c219f9a809f537611aec2e938201e87a53 Mon Sep 17 00:00:00 2001 From: CJ Winslow Date: Sun, 18 Jan 2026 03:01:39 -0800 Subject: [PATCH] refactor: clean up FilterableSelectList per code review - Remove dead input handlers (onSubmit/onEscape never triggered) - Store maxVisible as instance property instead of bracket access - Remove unused filterInput theme property --- src/tui/components/filterable-select-list.ts | 43 ++------------------ src/tui/theme/theme.ts | 1 - 2 files changed, 4 insertions(+), 40 deletions(-) diff --git a/src/tui/components/filterable-select-list.ts b/src/tui/components/filterable-select-list.ts index be64cc9fb..cc65e767f 100644 --- a/src/tui/components/filterable-select-list.ts +++ b/src/tui/components/filterable-select-list.ts @@ -15,7 +15,6 @@ export interface FilterableSelectItem extends SelectItem { export interface FilterableSelectListTheme extends SelectListTheme { filterLabel: (text: string) => string; - filterInput: (text: string) => string; } /** @@ -26,6 +25,7 @@ export class FilterableSelectList implements Component { private input: Input; private selectList: SelectList; private allItems: FilterableSelectItem[]; + private maxVisible: number; private theme: FilterableSelectListTheme; private filterText = ""; @@ -38,31 +38,11 @@ export class FilterableSelectList implements Component { theme: FilterableSelectListTheme, ) { this.allItems = items; + this.maxVisible = maxVisible; this.theme = theme; this.input = new Input(); this.selectList = new SelectList(items, maxVisible, theme); - - // Wire up input to filter the list - this.input.onSubmit = () => { - const selected = this.selectList.getSelectedItem(); - if (selected) { - this.onSelect?.(selected); - } - }; - - this.input.onEscape = () => { - if (this.filterText) { - // First escape clears filter - this.filterText = ""; - this.input.setValue(""); - this.selectList.setFilter(""); - this.selectList.setSelectedIndex(0); - } else { - // Second escape cancels - this.onCancel?.(); - } - }; } private getSearchText(item: FilterableSelectItem): string { @@ -75,29 +55,14 @@ export class FilterableSelectList implements Component { private applyFilter(): void { const query = this.filterText.toLowerCase().trim(); if (!query) { - // Reset to all items - this.selectList = new SelectList( - this.allItems, - this.selectList["maxVisible"], - this.theme, - ); - this.selectList.onSelect = this.onSelect; - this.selectList.onCancel = this.onCancel; + this.selectList = new SelectList(this.allItems, this.maxVisible, this.theme); return; } - // Use fuzzy filter from pi-tui const filtered = fuzzyFilter(this.allItems, query, (item) => this.getSearchText(item), ); - - this.selectList = new SelectList( - filtered, - this.selectList["maxVisible"], - this.theme, - ); - this.selectList.onSelect = this.onSelect; - this.selectList.onCancel = this.onCancel; + this.selectList = new SelectList(filtered, this.maxVisible, this.theme); } invalidate(): void { diff --git a/src/tui/theme/theme.ts b/src/tui/theme/theme.ts index ce071112e..18fa5f4d4 100644 --- a/src/tui/theme/theme.ts +++ b/src/tui/theme/theme.ts @@ -109,7 +109,6 @@ export const selectListTheme: SelectListTheme = { export const filterableSelectListTheme = { ...selectListTheme, filterLabel: (text: string) => fg(palette.dim)(text), - filterInput: (text: string) => fg(palette.text)(text), }; export const settingsListTheme: SettingsListTheme = {