Skip to content

fix(table): drive the category filter through the row model#278

Open
markdumay wants to merge 3 commits into
mainfrom
fix/table-filter
Open

fix(table): drive the category filter through the row model#278
markdumay wants to merge 3 commits into
mainfrom
fix/table-filter

Conversation

@markdumay

Copy link
Copy Markdown
Contributor

Companion to gethinode/hinode's category-filter fix.

Hinode now marks every filtered table as a data table, so a DataTable instance always exists by the time a filter button can be clicked. Two consequences here.

The DOM fallback is deleted

The click handler had a fallback branch that toggled display on each tbody tr directly when no DataTable existed. It is now unreachable — and it was the branch carrying a bug: it read row.cells[col] across every tbody tr, but a wrapped table renders two rows per record and the second holds a single <td colspan>. With the default filter-col = 1, cells[1] was undefined on that row, its text read as empty, and the description row was hidden the moment any filter became active — the record kept its data row but lost its description.

Filtering now always runs through simple-datatables' row model, so it composes correctly with sorting, pagination and the free-text search.

Clearing the filter no longer wipes a typed search

search(t, e, s = "search") ignores its source argument on the empty-term path — it unconditionally resets _searchQueries. So clicking All (whose data-filter-value is "") cleared every query source, including the user's typed search term: the input still showed the text while the model had forgotten it.

The empty-term case now uses multiSearch([], 'category-filter'), which drops only the queries whose source matches and re-concats the rest. This is what the library does for itself when its own search input is cleared.

Verified in a browser with a negative control on the same DataTable instance: the old call left _searchQueries = [], the new one leaves [search:alpha].

🤖 Generated with Claude Code

markdumay and others added 3 commits July 14, 2026 15:49
Hinode now marks every filtered table as a data table, so the fallback that
toggled row display directly is unreachable. It was also the branch carrying a
bug: it read row.cells[col] across every tbody tr, but a wrapped table's second
row per record holds a single colspan cell, so cells[1] was undefined and the
description row was hidden whenever a filter was active.

Filtering now always runs through the row model, so it composes with sorting,
pagination and the free-text search.
`search()` ignores its `source` argument on the empty-term path: it resets every query, so the
'All' button wiped a free-text term the visitor had typed along with the category filter. Clear
the filter with `multiSearch([], 'category-filter')` instead, which drops only the queries
carrying that source and re-concats the rest.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The block comment claimed every click routes through search(), but the
empty-term ("All") case calls multiSearch() instead, precisely because
search() ignores its source argument once the term is empty and would
wipe a visitor's free-text search. Describe both code paths and point
to the inline comment that explains the empty-term case.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant