Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 3.6k
fix(table-core): correct number-range, filter-depth, autoRemove, and custom faceting semantics#6503
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
fix(table-core): correct number-range, filter-depth, autoRemove, and custom faceting semantics #6503
Changes from all commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -283,25 +283,33 @@ When filtering is performed on the server, the rows loaded into the browser may | ||
| Each factory receives the table and a column ID, then returns a function that resolves the faceted result. The regular column APIs will return the server-provided values. | ||
| Factories are resolved once per table and column, but the function each factory returns runs on every read; the table does not cache its result. Read live values inside that returned function (from a signal, store, or `table.options.meta`) so updated server facets show up immediately, and memoize inside the factory if the calculation is expensive. | ||
coderabbitai[bot] marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| ```ts | ||
| const serverFacets = await fetch('/api/faceting').then((res) => res.json()) | ||
| // `local` is your Alpine.reactive state, refreshed when facets arrive | ||
| async function loadFacets() { | ||
| local.serverFacets = await fetch('/api/faceting').then((res) => res.json()) | ||
| } | ||
| const features = tableFeatures({ | ||
| columnFacetingFeature, | ||
| facetedUniqueValues: (_table, columnId) => () => { | ||
| const uniqueValueMap = new Map<string, number>() | ||
| // Populate the map from serverFacets data for columnId. | ||
| return uniqueValueMap | ||
| // The returned functions run on every read and table.options stays in | ||
| // sync with the latest render, so read live data through options.meta | ||
| facetedUniqueValues: (table, columnId) => () => { | ||
| const serverFacets = table.options.meta?.serverFacets | ||
| return new Map<string, number>(serverFacets?.uniqueValues[columnId] ?? []) | ||
| }, | ||
| facetedMinMaxValues: (_table, columnId) => () => { | ||
| // Read the range from serverFacets data for columnId. | ||
| return [min, max] | ||
| facetedMinMaxValues: (table, columnId) => () => { | ||
| return table.options.meta?.serverFacets?.minMaxValues[columnId] | ||
| }, | ||
| }) | ||
| const table = createTable({ | ||
| features, | ||
| columns, | ||
| get meta() { | ||
| return { serverFacets: local.serverFacets } | ||
| }, | ||
| get data() { | ||
| return local.data | ||
| }, | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -304,26 +304,29 @@ When filtering is performed on the server, the rows loaded into the browser may | ||
| Each factory receives the table and a column ID, then returns a function that resolves the faceted result. The regular column APIs will return the server-provided values. | ||
| ```ts | ||
| const serverFacets = await fetch('/api/faceting').then((res) => res.json()) | ||
| Factories are resolved once per table and column, but the function each factory returns runs on every read; the table does not cache its result. Read live values inside that returned function (from a signal, store, or `table.options.meta`) so updated server facets show up immediately, and memoize inside the factory if the calculation is expensive. | ||
coderabbitai[bot] marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| ```ts | ||
| // `this.serverFacets` is a @tracked field on your component, set when | ||
| // the facet request resolves | ||
| const features = tableFeatures({ | ||
| columnFacetingFeature, | ||
| facetedUniqueValues: (_table, columnId) => () => { | ||
| const uniqueValueMap = new Map<string, number>() | ||
| // Populate the map from serverFacets data for columnId. | ||
| return uniqueValueMap | ||
| // The returned functions run on every read and table.options stays in | ||
| // sync with the latest render, so read live data through options.meta | ||
| facetedUniqueValues: (table, columnId) => () => { | ||
| const serverFacets = table.options.meta?.serverFacets | ||
| return new Map<string, number>(serverFacets?.uniqueValues[columnId] ?? []) | ||
| }, | ||
| facetedMinMaxValues: (_table, columnId) => () => { | ||
| // Read the range from serverFacets data for columnId. | ||
| return [min, max] | ||
| facetedMinMaxValues: (table, columnId) => () => { | ||
| return table.options.meta?.serverFacets?.minMaxValues[columnId] | ||
| }, | ||
| }) | ||
| // Inside your Glimmer component: | ||
| table = useTable(() => ({ | ||
| features, | ||
| columns, | ||
| meta: { serverFacets: this.serverFacets }, | ||
| data: this.data, | ||
| })) | ||
| ``` | ||
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: TanStack/table
Length of output: 234
🏁 Script executed:
Repository: TanStack/table
Length of output: 50370
Split or relabel the step-4 line.
Step 4 currently merges PR
#6443(#5801expansion reset) and also describes Cluster 5 filtering fixes (#6007,#5987,#6101,#6081). The filtering fixes do not have a consolidated PR listed, so maintainers may treat the wrong PR as the vehicle for Cluster 5. Split this into separate steps, or replace the parenthetical with the actual Cluster 5 PR when available.🤖 Prompt for AI Agents