Overview
src/components/common/AdvancedDataGrid.tsx sort comparator does direct string/number comparison on cell values. When a row has null or undefined for a sorted column (missing data, optional fields), the comparator crashes with Cannot read properties of null (reading 'toLowerCase') or returns NaN from undefined - undefined, corrupting the sort order silently.
Specifications
Features:
- Sort comparator handles
null, undefined, and empty string as 'less than' all valid values
- Null/undefined rows sorted to end by default, configurable via
nullsFirst?: boolean prop
- String sort is case-insensitive and diacritic-normalized
- No crash or warning for any null/undefined cell value
Tasks:
- Add null guards in sort comparator:
if (a == null && b == null) return 0; if (a == null) return 1; if (b == null) return -1;
- Apply
normalize + toLowerCase for string comparison
- Add
nullsFirst prop to column definition type
- Add unit tests: sort with all-null column, mixed null/value column, and fully populated column
Impacted Files:
src/components/common/AdvancedDataGrid.tsx
Acceptance Criteria
- Sort on a column with null values does not throw
- Null values sort to end by default
nullsFirst={true} column prop reverses null position
- Unit tests pass for null-only, mixed, and value-only sort scenarios
Overview
src/components/common/AdvancedDataGrid.tsxsort comparator does direct string/number comparison on cell values. When a row hasnullorundefinedfor a sorted column (missing data, optional fields), the comparator crashes withCannot read properties of null (reading 'toLowerCase')or returnsNaNfromundefined - undefined, corrupting the sort order silently.Specifications
Features:
null,undefined, and empty string as 'less than' all valid valuesnullsFirst?: booleanpropTasks:
if (a == null && b == null) return 0; if (a == null) return 1; if (b == null) return -1;normalize+toLowerCasefor string comparisonnullsFirstprop to column definition typeImpacted Files:
src/components/common/AdvancedDataGrid.tsxAcceptance Criteria
nullsFirst={true}column prop reverses null position