Compare commits

...
Author SHA1 Message Date
Sonarly Claude Code 2b89fcc487 fix(spreadsheet-import): handle empty importedColumns in ValidationStep column filtering
https://sonarly.com/issue/33619?type=bug

The CSV import "Validate Data" step (step 3) renders a completely blank table because the column filtering logic in ValidationStep produces an empty columns array, causing SpreadsheetImportTable to return null.

Fix: Fixed the column filtering logic in `ValidationStep.tsx` that caused the CSV import validation table to render blank at Step 3.

**Three changes in a single `useMemo` block:**

1. **Extracted `select-row` to an early return**: The `column.key === 'select-row'` check was previously inside the `importedColumns.filter()` callback. When `importedColumns` was empty (no entries to iterate), the filter returned `[]` for ALL columns — including the row selection checkbox. Now `select-row` is handled with an early return before the `importedColumns` check, so it always renders.

2. **Replaced `.filter().length > 0` with `.some()`**: More idiomatic, more efficient (short-circuits on first match), and clearer intent.

3. **Added `'value' in importColumn` type guard**: Only compares `importColumn.value` on column types that actually have a `value` property (matched, matchedSelect, matchedSelectOptions, matchedCheckbox), safely skipping `empty` and `ignored` column types. Also restructured the boolean logic to check `value === column.key` once rather than repeating it for each type.
2026-05-03 00:20:40 +00:00
@@ -181,20 +181,20 @@ export const ValidationStep = ({
() =>
generateColumns(fields)
.map((column) => {
const hasBeenImported =
importedColumns.filter(
(importColumn) =>
(importColumn.type === SpreadsheetColumnType.matched &&
importColumn.value === column.key) ||
(importColumn.type === SpreadsheetColumnType.matchedSelect &&
importColumn.value === column.key) ||
(importColumn.type ===
SpreadsheetColumnType.matchedSelectOptions &&
importColumn.value === column.key) ||
(importColumn.type === SpreadsheetColumnType.matchedCheckbox &&
importColumn.value === column.key) ||
column.key === 'select-row',
).length > 0;
if (column.key === 'select-row') {
return column;
}
const hasBeenImported = importedColumns.some(
(importColumn) =>
'value' in importColumn &&
importColumn.value === column.key &&
(importColumn.type === SpreadsheetColumnType.matched ||
importColumn.type === SpreadsheetColumnType.matchedSelect ||
importColumn.type ===
SpreadsheetColumnType.matchedSelectOptions ||
importColumn.type === SpreadsheetColumnType.matchedCheckbox),
);
if (!hasBeenImported) return null;
return column;