Skip to content

Commit

Permalink
revert: revert freezed columns changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ravgeetdhillon committed Aug 8, 2024
1 parent 4d5cd1d commit cace3e7
Showing 1 changed file with 27 additions and 27 deletions.
54 changes: 27 additions & 27 deletions src/DataTable/DataTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ function DataTable<T>(props: TableProps<T>): JSX.Element {
footer = defaultProps.footer,
currentSortColumnId = defaultProps.currentSortColumnId,
currentSortDirection = defaultProps.currentSortDirection,
isInnerTable = defaultProps.isInnerTable,
// isInnerTable = defaultProps.isInnerTable,
} = props;

const {
Expand All @@ -139,27 +139,27 @@ function DataTable<T>(props: TableProps<T>): JSX.Element {
} = useColumns(columns, onColumnOrderChange, defaultSortFieldId, defaultSortAsc);

// Find index of last freezed column
const index = React.useMemo(
() =>
tableColumns.reduce((i, column) => {
if (column.freeze) {
i += 1;
}
return i;
}, 0),
[tableColumns],
);

const tableColumnsBasedOnTable = React.useMemo(() => {
if (!isInnerTable) {
return tableColumns;
}
return tableColumns.slice(0, index);
}, [index, isInnerTable, tableColumns]);

const freezedColumns = React.useMemo(() => {
return tableColumns.slice(0, index);
}, [index, tableColumns]);
// const index = React.useMemo(
// () =>
// tableColumns.reduce((i, column) => {
// if (column.freeze) {
// i += 1;
// }
// return i;
// }, 0),
// [tableColumns],
// );

// const tableColumnsBasedOnTable = React.useMemo(() => {
// if (!isInnerTable) {
// return tableColumns;
// }
// return tableColumns.slice(0, index);
// }, [index, isInnerTable, tableColumns]);

// const freezedColumns = React.useMemo(() => {
// return tableColumns.slice(0, index);
// }, [index, tableColumns]);

const [
{
Expand Down Expand Up @@ -498,7 +498,7 @@ function DataTable<T>(props: TableProps<T>): JSX.Element {
</>
)}

{tableColumnsBasedOnTable.map(column => (
{tableColumns.map(column => (
<Column
key={column.id}
column={column}
Expand Down Expand Up @@ -546,7 +546,7 @@ function DataTable<T>(props: TableProps<T>): JSX.Element {
key={id}
keyField={keyField}
data-row-id={id}
columns={tableColumnsBasedOnTable}
columns={tableColumns}
row={row}
rowCount={sortedData.length}
rowIndex={i}
Expand Down Expand Up @@ -597,11 +597,11 @@ function DataTable<T>(props: TableProps<T>): JSX.Element {
</Wrapper>
</ResponsiveWrapper>

{freezedColumns.length > 0 && (
{/* {freezedColumns.length > 0 && (
<div
style={{
position: 'absolute',
top: 0,
top: '200px',
left: 0,
maxWidth: '100%',
}}
Expand Down Expand Up @@ -715,7 +715,7 @@ function DataTable<T>(props: TableProps<T>): JSX.Element {
</Table>
{footer && <div>{footer}</div>}
</div>
)}
)} */}
</div>

{enabledPagination && (
Expand Down

0 comments on commit cace3e7

Please sign in to comment.