Skip to content

Commit 0d1f3cf

Browse files
committed
fix: column auto sort slice
fix: column resizing passive detection
1 parent a06e310 commit 0d1f3cf

3 files changed

Lines changed: 8 additions & 9 deletions

File tree

packages/table-core/src/features/column-resizing/columnResizingFeature.utils.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,7 @@ export function table_resetHeaderSizeInfo<
314314
)
315315
}
316316

317+
let passiveSupported: boolean | null = null
317318
/**
318319
* Detects whether the current environment supports passive event listeners.
319320
*
@@ -326,8 +327,6 @@ export function table_resetHeaderSizeInfo<
326327
* ```
327328
*/
328329
export function passiveEventSupported() {
329-
let passiveSupported: boolean | null = null
330-
331330
if (typeof passiveSupported === 'boolean') return passiveSupported
332331

333332
let supported = false

packages/table-core/src/features/row-sorting/rowSortingFeature.utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ export function column_getAutoSortFn<
9191

9292
let sortFn: SortFn<TFeatures, TData> | undefined
9393

94-
const firstRows = column.table.getFilteredRowModel().flatRows.slice(10)
94+
const firstRows = column.table.getFilteredRowModel().flatRows.slice(0, 10)
9595

9696
let isString = false
9797

perf.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,10 @@ Typecheck verified clean after the sweep (`pnpm tsc --noEmit` passes).
9494
## Progress
9595

9696
- **Total findings:** 60
97-
- **Done `[x]`:** 15
97+
- **Done `[x]`:** 17
9898
- **Partial `[~]`:** 2
9999
- **Skipped `[-]`:** 1
100-
- **Not started `[ ]`:** 42
100+
- **Not started `[ ]`:** 40
101101

102102
_(Update these counters as you go.)_
103103

@@ -1338,8 +1338,8 @@ return allCells.filter((d) => !leftAndRight.has(d.column.id))
13381338

13391339
## 37. `passiveEventSupported()` caching bug — Score: 8 (bug)
13401340

1341-
**Status:** `[ ]` not started
1342-
**Implementation note:** _(none)_
1341+
**Status:** `[x]` done
1342+
**Implementation note:** Hoisted `let passiveSupported: boolean | null = null` from inside the function to module scope. Previously the cache check `if (typeof passiveSupported === 'boolean') return passiveSupported` was unreachable on first call and the variable was reset to `null` on every subsequent call, so each invocation re-probed the DOM via `window.addEventListener('test', ...)` + `removeEventListener`. After the hoist the cache actually persists: first call probes once, all later calls short-circuit. Implemented exactly as proposed.
13431343

13441344
**Location:** `src/features/column-resizing/columnResizingFeature.utils.ts:320–343`
13451345
**Category:** `bug`, `micro`
@@ -1809,8 +1809,8 @@ return indexed.map((x) => x.row)
18091809

18101810
## 50. `column_getAutoSortFn` `slice(10)` should be `slice(0, 10)` (bug) — Score: 7 (bug)
18111811

1812-
**Status:** `[ ]` not started
1813-
**Implementation note:** _(none)_
1812+
**Status:** `[x]` done
1813+
**Implementation note:** One-character fix — `slice(10)``slice(0, 10)`. Now correctly samples the first 10 filtered rows for sort-fn auto-detection instead of dropping the first 10 and taking everything after. With ≤10 rows the prior `slice(10)` returned an empty array, so the loop was a no-op and the function silently fell back to the basic/alphanumeric default regardless of actual data types. No existing tests pinned the broken behavior; typecheck clean.
18141814

18151815
**Location:** `src/features/row-sorting/rowSortingFeature.utils.ts:79–114`
18161816
**Category:** `bug`

0 commit comments

Comments
 (0)