Skip to content

Commit

Permalink
[Content] Show that table is sorted in Last Saved desc when no other …
Browse files Browse the repository at this point in the history
  • Loading branch information
finnar-bin authored Aug 6, 2024
1 parent 4b76474 commit 13cf24f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
11 changes: 10 additions & 1 deletion src/apps/content-editor/src/app/views/ItemList/ItemListTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,16 @@ export const ItemListTable = memo(({ loading, rows }: ItemListTableProps) => {
sortModel={sortModel}
sortingMode="server"
onSortModelChange={(newSortModel) => {
setSortModel(newSortModel);
if (!Object.entries(newSortModel)?.length) {
setSortModel([
{
field: "lastSaved",
sort: "desc",
},
]);
} else {
setSortModel(newSortModel);
}
}}
onSelectionModelChange={(newSelection) => setSelectedItems(newSelection)}
selectionModel={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,13 @@ type TableSortProviderType = {
children?: React.ReactNode;
};
export const TableSortProvider = ({ children }: TableSortProviderType) => {
const [sortModel, setSortModel] = useState<GridSortModel>([]);
// Note: We always want it to default to lastSaved if no other sorting is applied
const [sortModel, setSortModel] = useState<GridSortModel>([
{
field: "lastSaved",
sort: "desc",
},
]);
const { modelZUID } = useRouterParams<{ modelZUID: string }>();

useLayoutEffect(() => {
Expand Down

0 comments on commit 13cf24f

Please sign in to comment.