diff --git a/react/community/tanstack-table-carbon/src/lib/utils/__tests__/columnHelpers.test.jsx b/react/community/tanstack-table-carbon/src/lib/utils/__tests__/columnHelpers.test.jsx index bea5539..21086c0 100644 --- a/react/community/tanstack-table-carbon/src/lib/utils/__tests__/columnHelpers.test.jsx +++ b/react/community/tanstack-table-carbon/src/lib/utils/__tests__/columnHelpers.test.jsx @@ -331,6 +331,33 @@ describe('enhanceColumnsWithSmartFiltering', () => { }); }); + describe('radio filterFn', () => { + const col = { id: 'gender', meta: { filterVariant: 'radio' } }; + const [enhanced] = enhanceColumnsWithSmartFiltering([col]); + + it('matches exact value only, not substrings', () => { + const maleRow = { getValue: () => 'Male' }; + const femaleRow = { getValue: () => 'Female' }; + expect(enhanced.filterFn(maleRow, 'gender', '')).toBe(true); + expect(enhanced.filterFn(maleRow, 'gender', 'Male')).toBe(true); + expect(enhanced.filterFn(femaleRow, 'gender', 'Male')).toBe(false); + expect(enhanced.filterFn(femaleRow, 'gender', 'Female')).toBe(true); + }); + }); + + describe('select filterFn', () => { + const col = { id: 'location', meta: { filterVariant: 'select' } }; + const [enhanced] = enhanceColumnsWithSmartFiltering([col]); + + it('matches exact value only, not substrings', () => { + const newYorkRow = { getValue: () => 'New York' }; + const yorkRow = { getValue: () => 'York' }; + expect(enhanced.filterFn(newYorkRow, 'location', null)).toBe(true); + expect(enhanced.filterFn(newYorkRow, 'location', 'York')).toBe(false); + expect(enhanced.filterFn(yorkRow, 'location', 'York')).toBe(true); + }); + }); + describe('time filterFn', () => { const col = { id: 'time', meta: { filterVariant: 'time' } }; const [enhanced] = enhanceColumnsWithSmartFiltering([col]); diff --git a/react/community/tanstack-table-carbon/src/lib/utils/__tests__/stickyColumnHelpers.test.js b/react/community/tanstack-table-carbon/src/lib/utils/__tests__/stickyColumnHelpers.test.js index 6a7ef35..4b90bbc 100644 --- a/react/community/tanstack-table-carbon/src/lib/utils/__tests__/stickyColumnHelpers.test.js +++ b/react/community/tanstack-table-carbon/src/lib/utils/__tests__/stickyColumnHelpers.test.js @@ -23,7 +23,6 @@ describe('stickyColumnHelpers', () => { borderLeft: 0, left: '24px', right: undefined, - opacity: 0.95, position: 'sticky', width: '180px', minWidth: '180px', @@ -50,7 +49,6 @@ describe('stickyColumnHelpers', () => { borderLeft: '1px solid var(--cds-border-subtle)', left: undefined, right: '36px', - opacity: 0.95, position: 'sticky', width: '120px', minWidth: '120px', @@ -75,7 +73,6 @@ describe('stickyColumnHelpers', () => { borderLeft: 0, left: undefined, right: undefined, - opacity: 1, position: 'relative', zIndex: 0, }); diff --git a/react/community/tanstack-table-carbon/src/lib/utils/columnHelpers.jsx b/react/community/tanstack-table-carbon/src/lib/utils/columnHelpers.jsx index 831ebbb..c2c2e8f 100644 --- a/react/community/tanstack-table-carbon/src/lib/utils/columnHelpers.jsx +++ b/react/community/tanstack-table-carbon/src/lib/utils/columnHelpers.jsx @@ -219,6 +219,20 @@ export const enhanceColumnsWithSmartFiltering = (columns) => { }; } + // NOTE: Radio / select filter — filterValue is one exact option from the column's unique + // values. The default string filter uses "includes", so "Male" would also match "Female". + if (filterVariant === 'radio' || filterVariant === 'select') { + return { + ...column, + filterFn: (row, columnId, filterValue) => { + if (filterValue === '' || filterValue === undefined || filterValue === null) { + return true; + } + return String(row.getValue(columnId)) === String(filterValue); + }, + }; + } + // NOTE: Time filter — filterValue is a string like "09:30 AM". // Raw column value is typically "09:30" (HH:MM, no period). // Match if the raw value is contained within the filter string or vice-versa. diff --git a/react/community/tanstack-table-carbon/src/lib/utils/stickyColumnHelpers.js b/react/community/tanstack-table-carbon/src/lib/utils/stickyColumnHelpers.js index 7207200..71630fa 100644 --- a/react/community/tanstack-table-carbon/src/lib/utils/stickyColumnHelpers.js +++ b/react/community/tanstack-table-carbon/src/lib/utils/stickyColumnHelpers.js @@ -20,7 +20,6 @@ export const getCommonPinningStyles = (column, isHeader = false) => { : 0, left: isPinned === 'left' ? `${column.getStart('left')}px` : undefined, right: isPinned === 'right' ? `${column.getAfter('right')}px` : undefined, - opacity: isPinned ? 0.95 : 1, position: isPinned ? 'sticky' : 'relative', /* NOTE: Pinned (sticky) columns always need an explicit width and min-width so that: 1. The cell does not grow/shrink with its content — sticky cells must be fixed-size.