@@ -17,6 +17,7 @@ import { parseDateToUTC } from "../utils/dateUtils";
1717
1818export class TaskListView extends BasesViewBase {
1919 type = "tasknoteTaskList" ;
20+
2021 private itemsContainer : HTMLElement | null = null ;
2122 private currentTaskElements = new Map < string , HTMLElement > ( ) ;
2223 private lastRenderWasGrouped = false ;
@@ -32,6 +33,7 @@ export class TaskListView extends BasesViewBase {
3233 private collapsedSubGroups = new Set < string > ( ) ; // Track collapsed sub-group keys
3334 private subGroupPropertyId : string | null = null ; // Property ID for sub-grouping
3435 private configLoaded = false ; // Track if we've successfully loaded config
36+
3537 /**
3638 * Threshold for enabling virtual scrolling in task list view.
3739 * Virtual scrolling activates when total items (tasks + group headers) >= 100.
@@ -64,11 +66,15 @@ export class TaskListView extends BasesViewBase {
6466 private readViewOptions ( ) : void {
6567 // Guard: config may not be set yet if called too early
6668 if ( ! this . config || typeof this . config . get !== 'function' ) {
69+ console . debug ( '[TaskListView] Config not available yet in readViewOptions' ) ;
6770 return ;
6871 }
6972
7073 try {
7174 this . subGroupPropertyId = this . config . getAsPropertyId ( 'subGroup' ) ;
75+ // Read enableSearch toggle (default: false for backward compatibility)
76+ const enableSearchValue = this . config . get ( 'enableSearch' ) ;
77+ this . enableSearch = ( enableSearchValue as boolean ) ?? false ;
7278 // Mark config as successfully loaded
7379 this . configLoaded = true ;
7480 } catch ( e ) {
@@ -105,6 +111,11 @@ export class TaskListView extends BasesViewBase {
105111 this . readViewOptions ( ) ;
106112 }
107113
114+ // Now that config is loaded, setup search (idempotent: will only create once)
115+ if ( this . rootElement ) {
116+ this . setupSearch ( this . rootElement ) ;
117+ }
118+
108119 try {
109120 // Skip rendering if we have no data yet (prevents flickering during data updates)
110121 if ( ! this . data ?. data ) {
@@ -211,6 +222,9 @@ export class TaskListView extends BasesViewBase {
211222 private async renderFlat ( taskNotes : TaskInfo [ ] ) : Promise < void > {
212223 const visibleProperties = this . getVisibleProperties ( ) ;
213224
225+ // Apply search filter
226+ const filteredTasks = this . applySearchFilter ( taskNotes ) ;
227+
214228 // Note: taskNotes are already sorted by Bases according to sort configuration
215229 // No manual sorting needed - Bases provides pre-sorted data
216230
@@ -219,8 +233,8 @@ export class TaskListView extends BasesViewBase {
219233
220234 const cardOptions = this . getCardOptions ( targetDate ) ;
221235
222- // Decide whether to use virtual scrolling
223- const shouldUseVirtualScrolling = taskNotes . length >= this . VIRTUAL_SCROLL_THRESHOLD ;
236+ // Decide whether to use virtual scrolling based on filtered task count
237+ const shouldUseVirtualScrolling = filteredTasks . length >= this . VIRTUAL_SCROLL_THRESHOLD ;
224238
225239 if ( shouldUseVirtualScrolling && ! this . useVirtualScrolling ) {
226240 // Switch to virtual scrolling
@@ -233,9 +247,9 @@ export class TaskListView extends BasesViewBase {
233247 }
234248
235249 if ( this . useVirtualScrolling ) {
236- await this . renderFlatVirtual ( taskNotes , visibleProperties , cardOptions ) ;
250+ await this . renderFlatVirtual ( filteredTasks , visibleProperties , cardOptions ) ;
237251 } else {
238- await this . renderFlatNormal ( taskNotes , visibleProperties , cardOptions ) ;
252+ await this . renderFlatNormal ( filteredTasks , visibleProperties , cardOptions ) ;
239253 }
240254 }
241255
@@ -423,13 +437,17 @@ export class TaskListView extends BasesViewBase {
423437 */
424438 private async renderGroupedBySubProperty ( taskNotes : TaskInfo [ ] ) : Promise < void > {
425439 const visibleProperties = this . getVisibleProperties ( ) ;
440+
441+ // Apply search filter
442+ const filteredTasks = this . applySearchFilter ( taskNotes ) ;
443+
426444 const targetDate = new Date ( ) ;
427445 this . currentTargetDate = targetDate ;
428446 const cardOptions = this . getCardOptions ( targetDate ) ;
429447
430448 // Group tasks by sub-property
431449 const pathToProps = this . buildPathToPropsMap ( ) ;
432- const groupedTasks = this . groupTasksBySubProperty ( taskNotes , this . subGroupPropertyId ! , pathToProps ) ;
450+ const groupedTasks = this . groupTasksBySubProperty ( filteredTasks , this . subGroupPropertyId ! , pathToProps ) ;
433451
434452 // Build flat items array (treat sub-groups as primary groups)
435453 type RenderItem =
@@ -497,12 +515,15 @@ export class TaskListView extends BasesViewBase {
497515 const visibleProperties = this . getVisibleProperties ( ) ;
498516 const groups = this . dataAdapter . getGroupedData ( ) ;
499517
518+ // Apply search filter
519+ const filteredTasks = this . applySearchFilter ( taskNotes ) ;
520+
500521 const targetDate = new Date ( ) ;
501522 this . currentTargetDate = targetDate ;
502523 const cardOptions = this . getCardOptions ( targetDate ) ;
503524
504525 // Build flattened list of items using shared method
505- const items = this . buildGroupedRenderItems ( groups , taskNotes ) ;
526+ const items = this . buildGroupedRenderItems ( groups , filteredTasks ) ;
506527
507528 // Use virtual scrolling if we have many items
508529 const shouldUseVirtualScrolling = items . length >= this . VIRTUAL_SCROLL_THRESHOLD ;
@@ -718,10 +739,11 @@ export class TaskListView extends BasesViewBase {
718739 * Override from Component base class.
719740 */
720741 onunload ( ) : void {
721- // Component.register() calls will be automatically cleaned up
742+ // Component.register() calls will be automatically cleaned up (including search cleanup)
722743 // We just need to clean up view-specific state
723744 this . unregisterContainerListeners ( ) ;
724745 this . destroyVirtualScroller ( ) ;
746+
725747 this . currentTaskElements . clear ( ) ;
726748 this . itemsContainer = null ;
727749 this . lastRenderWasGrouped = false ;
0 commit comments