Skip to content

Commit 57c3e9a

Browse files
committed
fix: Table row styling alignment issues, inner child listing
1 parent 0c83f71 commit 57c3e9a

File tree

4 files changed

+41
-30
lines changed

4 files changed

+41
-30
lines changed

src/components/MultiLevelTable.tsx

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -438,22 +438,25 @@ export const MultiLevelTable: React.FC<MultiLevelTableProps> = ({
438438
if (!children || !expandedRows.has(parentId)) return null;
439439

440440
return children.map((child) => (
441-
<TableRow
442-
key={child.id}
443-
row={child}
444-
columns={columns}
445-
hasChildren={!!child.children && child.children.length > 0}
446-
isExpanded={expandedRows.has(child.id)}
447-
onToggle={() => onRowToggle(child.id)}
448-
level={level}
449-
theme={mergedTheme}
450-
selectable={selectable}
451-
isRowSelected={selectionState.selectedRows.has(child.id)}
452-
onRowSelect={() => onRowSelect(child.id)}
453-
onRowClick={onRowClick}
454-
onDelete={handleDeleteClick}
455-
expandIcon={expandIcon}
456-
/>
441+
<React.Fragment key={child.id}>
442+
<TableRow
443+
row={child}
444+
columns={columns}
445+
hasChildren={!!child.children && child.children.length > 0}
446+
isExpanded={expandedRows.has(child.id)}
447+
onToggle={() => onRowToggle(child.id)}
448+
level={level}
449+
theme={mergedTheme}
450+
selectable={selectable}
451+
isRowSelected={selectionState.selectedRows.has(child.id)}
452+
onRowSelect={() => onRowSelect(child.id)}
453+
onRowClick={onRowClick}
454+
onDelete={handleDeleteClick}
455+
expandIcon={expandIcon}
456+
/>
457+
{/* Recursively render nested children */}
458+
{child.children && child.children.length > 0 && renderNestedRows(child.id, level + 1)}
459+
</React.Fragment>
457460
));
458461
};
459462

src/components/TableCell.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,14 +108,17 @@ export const TableCell: React.FC<TableCellProps> = ({
108108
cell.render('Cell')
109109
) : (
110110
<>
111-
{hasChildren ? (
111+
{/* Only show expand button in the first column when row has children */}
112+
{index === 0 && hasChildren ? (
112113
<div
113114
onClick={handleExpandClick}
114115
className="expand-button"
115116
>
116117
{expandIcon || <ExpandIcon isExpanded={isExpanded} theme={theme} mode="expand" />}
117118
</div>
118-
) : <div className="expand-button" />}
119+
) : index === 0 ? (
120+
<div className="expand-button" />
121+
) : null}
119122
{cell.render('Cell')}
120123
</>
121124
)}

src/components/TableRow.tsx

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -141,14 +141,19 @@ export const TableRow: React.FC<TableRowProps> = ({
141141
<div className="placeholder-spacer" />
142142
)}
143143

144-
<div
145-
onClick={handleExpandClick}
146-
className={`expand-button ${isParentRow || index !== 0 ? 'parent-row-expand-button' : 'nested-row-expand-button'} ${hasChildren && index === 0 ? 'expand-button-visible' : 'expand-button-hidden'}`}
147-
>
148-
{expandIcon || (
149-
<ExpandIcon isExpanded={isExpanded} theme={theme} mode="expand" />
150-
)}
151-
</div>
144+
{/* Only show expand button in the first column when row has children */}
145+
{index === 0 && (
146+
<div
147+
onClick={handleExpandClick}
148+
className={`expand-button ${isParentRow || index !== 0 ? 'parent-row-expand-button' : 'nested-row-expand-button'} ${hasChildren ? 'expand-button-visible' : 'expand-button-hidden'}`}
149+
>
150+
{hasChildren ? (
151+
expandIcon || (
152+
<ExpandIcon isExpanded={isExpanded} theme={theme} mode="expand" />
153+
)
154+
) : null}
155+
</div>
156+
)}
152157

153158
{column.render
154159
? column.render(displayValue, dataItem)

src/styles/Pagination.css

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,14 +92,14 @@
9292
.pagination-total-items {
9393
display: block;
9494
}
95-
}
96-
95+
}
96+
9797
/* Hide total items text on screens smaller than 798px */
9898
@media (max-width: 797px) {
9999
.pagination-total-items {
100100
display: none;
101-
}
102-
101+
}
102+
103103
.pagination-container {
104104
min-width: 1200px; /* Maintain minimum width */
105105
overflow-x: auto; /* Enable horizontal scroll */

0 commit comments

Comments
 (0)