Skip to content

Commit

Permalink
fix broken defaultSortFieldId
Browse files Browse the repository at this point in the history
  • Loading branch information
jbetancur committed Sep 11, 2021
1 parent 4db6de3 commit d2e9b39
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/DataTable/TableCol.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ interface ColumnSortableProps {

const sortableCSS = css<ColumnSortableProps>`
${({ theme }) => theme.headCells.sortStyle};
span.__rdt_custom_sort_icon__ {
i,
svg {
transform: 'translate3d(0, 0, 0)';
${({ sortActive }) => (sortActive ? 'opacity: 1' : 'opacity: 0')};
color: inherit;
font-size: 18px !important;
Expand Down
94 changes: 91 additions & 3 deletions src/DataTable/__tests__/__snapshots__/DataTable.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -3253,8 +3253,15 @@ exports[`DataTable::Pagination should navigate to page 1 if the table is sorted
color: rgba(0,0,0,.54);
}

.c7:hover:active {
color: rgba(0,0,0,.54);
}

.c7 span.__rdt_custom_sort_icon__ i,
.c7 span.__rdt_custom_sort_icon__ svg {
-webkit-transform: 'translate3d(0, 0, 0)';
-ms-transform: 'translate3d(0, 0, 0)';
transform: 'translate3d(0, 0, 0)';
opacity: 1;
color: inherit;
font-size: 18px !important;
Expand Down Expand Up @@ -9656,8 +9663,15 @@ exports[`DataTable::columns should render correctly when column.sortable = true
color: rgba(0,0,0,.54);
}

.c7:hover:active {
color: rgba(0,0,0,.54);
}

.c7 span.__rdt_custom_sort_icon__ i,
.c7 span.__rdt_custom_sort_icon__ svg {
-webkit-transform: 'translate3d(0, 0, 0)';
-ms-transform: 'translate3d(0, 0, 0)';
transform: 'translate3d(0, 0, 0)';
opacity: 0;
color: inherit;
font-size: 18px !important;
Expand Down Expand Up @@ -21303,8 +21317,15 @@ exports[`DataTable::sorting a custom column sorting function is used 1`] = `
color: rgba(0,0,0,.54);
}

.c7:hover:active {
color: rgba(0,0,0,.54);
}

.c7 span.__rdt_custom_sort_icon__ i,
.c7 span.__rdt_custom_sort_icon__ svg {
-webkit-transform: 'translate3d(0, 0, 0)';
-ms-transform: 'translate3d(0, 0, 0)';
transform: 'translate3d(0, 0, 0)';
opacity: 1;
color: inherit;
font-size: 18px !important;
Expand Down Expand Up @@ -21624,8 +21645,15 @@ exports[`DataTable::sorting should render correctly and bypass internal sort whe
color: rgba(0,0,0,.54);
}

.c7:hover:active {
color: rgba(0,0,0,.54);
}

.c7 span.__rdt_custom_sort_icon__ i,
.c7 span.__rdt_custom_sort_icon__ svg {
-webkit-transform: 'translate3d(0, 0, 0)';
-ms-transform: 'translate3d(0, 0, 0)';
transform: 'translate3d(0, 0, 0)';
opacity: 1;
color: inherit;
font-size: 18px !important;
Expand Down Expand Up @@ -21911,9 +21939,6 @@ exports[`DataTable::sorting should render correctly and bypass internal sort whe
-ms-flex-negative: 0;
flex-shrink: 0;
opacity: 1;
-webkit-transform: rotate(180deg);
-ms-transform: rotate(180deg);
transform: rotate(180deg);
}

.c7 {
Expand Down Expand Up @@ -21948,8 +21973,15 @@ exports[`DataTable::sorting should render correctly and bypass internal sort whe
color: rgba(0,0,0,.54);
}

.c7:hover:active {
color: rgba(0,0,0,.54);
}

.c7 span.__rdt_custom_sort_icon__ i,
.c7 span.__rdt_custom_sort_icon__ svg {
-webkit-transform: 'translate3d(0, 0, 0)';
-ms-transform: 'translate3d(0, 0, 0)';
transform: 'translate3d(0, 0, 0)';
opacity: 1;
color: inherit;
font-size: 18px !important;
Expand Down Expand Up @@ -22533,8 +22565,15 @@ exports[`DataTable::sorting should render correctly when a column is sorted from
color: rgba(0,0,0,.54);
}

.c7:hover:active {
color: rgba(0,0,0,.54);
}

.c7 span.__rdt_custom_sort_icon__ i,
.c7 span.__rdt_custom_sort_icon__ svg {
-webkit-transform: 'translate3d(0, 0, 0)';
-ms-transform: 'translate3d(0, 0, 0)';
transform: 'translate3d(0, 0, 0)';
opacity: 1;
color: inherit;
font-size: 18px !important;
Expand Down Expand Up @@ -22854,8 +22893,15 @@ exports[`DataTable::sorting should render correctly when a column is sorted in d
color: rgba(0,0,0,.54);
}

.c7:hover:active {
color: rgba(0,0,0,.54);
}

.c7 span.__rdt_custom_sort_icon__ i,
.c7 span.__rdt_custom_sort_icon__ svg {
-webkit-transform: 'translate3d(0, 0, 0)';
-ms-transform: 'translate3d(0, 0, 0)';
transform: 'translate3d(0, 0, 0)';
opacity: 1;
color: inherit;
font-size: 18px !important;
Expand Down Expand Up @@ -23162,8 +23208,15 @@ exports[`DataTable::sorting should render correctly with a custom sortIcon 1`] =
color: rgba(0,0,0,.54);
}

.c7:hover:active {
color: rgba(0,0,0,.54);
}

.c7 span.__rdt_custom_sort_icon__ i,
.c7 span.__rdt_custom_sort_icon__ svg {
-webkit-transform: 'translate3d(0, 0, 0)';
-ms-transform: 'translate3d(0, 0, 0)';
transform: 'translate3d(0, 0, 0)';
opacity: 0;
color: inherit;
font-size: 18px !important;
Expand Down Expand Up @@ -23481,8 +23534,15 @@ exports[`DataTable::sorting should render correctly with a custom sortIcon and c
color: rgba(0,0,0,.54);
}

.c7:hover:active {
color: rgba(0,0,0,.54);
}

.c7 span.__rdt_custom_sort_icon__ i,
.c7 span.__rdt_custom_sort_icon__ svg {
-webkit-transform: 'translate3d(0, 0, 0)';
-ms-transform: 'translate3d(0, 0, 0)';
transform: 'translate3d(0, 0, 0)';
opacity: 0;
color: inherit;
font-size: 18px !important;
Expand Down Expand Up @@ -23813,8 +23873,15 @@ exports[`DataTable::sorting should render correctly with a default sort field an
color: rgba(0,0,0,.54);
}

.c7:hover:active {
color: rgba(0,0,0,.54);
}

.c7 span.__rdt_custom_sort_icon__ i,
.c7 span.__rdt_custom_sort_icon__ svg {
-webkit-transform: 'translate3d(0, 0, 0)';
-ms-transform: 'translate3d(0, 0, 0)';
transform: 'translate3d(0, 0, 0)';
opacity: 0;
color: inherit;
font-size: 18px !important;
Expand Down Expand Up @@ -24139,8 +24206,15 @@ exports[`DataTable::sorting should render correctly with a default sort field an
color: rgba(0,0,0,.54);
}

.c7:hover:active {
color: rgba(0,0,0,.54);
}

.c7 span.__rdt_custom_sort_icon__ i,
.c7 span.__rdt_custom_sort_icon__ svg {
-webkit-transform: 'translate3d(0, 0, 0)';
-ms-transform: 'translate3d(0, 0, 0)';
transform: 'translate3d(0, 0, 0)';
opacity: 0;
color: inherit;
font-size: 18px !important;
Expand Down Expand Up @@ -24468,8 +24542,15 @@ exports[`DataTable::sorting should render correctly with a defaultSortAsc = fals
color: rgba(0,0,0,.54);
}

.c7:hover:active {
color: rgba(0,0,0,.54);
}

.c7 span.__rdt_custom_sort_icon__ i,
.c7 span.__rdt_custom_sort_icon__ svg {
-webkit-transform: 'translate3d(0, 0, 0)';
-ms-transform: 'translate3d(0, 0, 0)';
transform: 'translate3d(0, 0, 0)';
opacity: 0;
color: inherit;
font-size: 18px !important;
Expand Down Expand Up @@ -24797,8 +24878,15 @@ exports[`DataTable::sorting should sort if the column is selected and the Enter
color: rgba(0,0,0,.54);
}

.c7:hover:active {
color: rgba(0,0,0,.54);
}

.c7 span.__rdt_custom_sort_icon__ i,
.c7 span.__rdt_custom_sort_icon__ svg {
-webkit-transform: 'translate3d(0, 0, 0)';
-ms-transform: 'translate3d(0, 0, 0)';
transform: 'translate3d(0, 0, 0)';
opacity: 1;
color: inherit;
font-size: 18px !important;
Expand Down
3 changes: 3 additions & 0 deletions src/DataTable/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ export const defaultStyles = (theme: Theme): TableStyles => ({
'&:hover': {
color: theme.sortFocus.default,
},
'&:hover:active': {
color: theme.sortFocus.default,
},
},
},
contextMenu: {
Expand Down
4 changes: 2 additions & 2 deletions src/hooks/useColumns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ function useColumns<T>(

const defaultSortDirection = getSortDirection(defaultSortAsc);
const defaultSortColumn = React.useMemo(
() => columns[findColumnIndexById(columns, defaultSortFieldId?.toString())] || {},
[columns, defaultSortFieldId],
() => tableColumns[findColumnIndexById(tableColumns, defaultSortFieldId?.toString())] || {},
[defaultSortFieldId, tableColumns],
);

return {
Expand Down

0 comments on commit d2e9b39

Please sign in to comment.