fix(table): drive the category filter through the row model#278
Open
markdumay wants to merge 3 commits into
Open
fix(table): drive the category filter through the row model#278markdumay wants to merge 3 commits into
markdumay wants to merge 3 commits into
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
displayon eachtbody trdirectly when no DataTable existed. It is now unreachable — and it was the branch carrying a bug: it readrow.cells[col]across everytbody tr, but a wrapped table renders two rows per record and the second holds a single<td colspan>. With the defaultfilter-col = 1,cells[1]wasundefinedon 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 itssourceargument on the empty-term path — it unconditionally resets_searchQueries. So clicking All (whosedata-filter-valueis"") 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 whosesourcematches 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