Loading workspace insights... Statistics interval
7 days30 daysLatest CI Pipeline Executions
56ab4734 fix(table-core): guard Array.isArray before index access in range filter autoRemove (#6394)
* fix(table-core): guard Array.isArray before index access in range filter autoRemove
`filterFn_between`, `filterFn_betweenInclusive`, and
`filterFn_inNumberRange` shared an `autoRemove` that did
`testFalsy(val[0]) && testFalsy(val[1])`. When a scalar value such as
`99` was passed instead of a `[min, max]` tuple, `val[0]` and
`val[1]` were both `undefined`, so the condition evaluated to
`true && true` and the filter was silently auto-removed.
Numeric columns default to `inNumberRange` via
`column_getAutoFilterFn`, so calling `col.setColumnFilter(99)` on a
numeric column discarded the filter before the row scan even ran.
Wrap the index checks in `Array.isArray(val) &&`. The leading
`testFalsy(val)` still handles `undefined`, `null`, `0`, and
`''`. Behavior of the existing array-tuple cases is unchanged because
`Array.isArray` is true and short-circuits to the same boolean.
Closes #6353
* test(filterFns): assert empty-string scalar IS auto-removed
The previous regression test for #6353 bundled the non-empty scalar
case (autoRemove(99) and autoRemove(0)) with an empty-string
expectation (autoRemove('')). testFalsy treats '' as falsy, so the
leading testFalsy(val) branch correctly returns true for '' - the
Array.isArray guard added in 0041efb is intentionally additive and
not meant to override that behavior.
Split the assertion: the non-empty scalar test now stands alone with
just autoRemove(99) and autoRemove(0); the empty-string behavior is
covered by a separate explicit assertion (expect(autoRemove(''))).toBe(true))
Vitest run:
Test Files 1 passed (1)
Tests 73 passed (73)
Signed-off-by: sanjibani <18418553+sanjibani@users.noreply.github.com>
---------
Signed-off-by: sanjibani <18418553+sanjibani@users.noreply.github.com>
Co-authored-by: sanjibani <18418553+sanjibani@users.noreply.github.com>
Co-authored-by: JSap0914