Skip to content

Commit

Permalink
PR comment: fix when sorting from table column
Browse files Browse the repository at this point in the history
  • Loading branch information
arome committed Oct 24, 2024
1 parent 826fe0d commit 6818c9a
Showing 1 changed file with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,15 @@ export const IModelGrid = ({
viewMode,
maxCount,
}: IModelGridProps) => {
const [sort, setSort] = React.useState<IModelSortOptions>(sortOptions);
const [isSortOnTable, setIsSortOnTable] = React.useState(false);

React.useEffect(() => {
if (!isSortOnTable) {
setSort({ sortType: "name", descending: sortOptions.descending });
}
}, [isSortOnTable, sortOptions.descending]);

const strings = _mergeStrings(
{
tableColumnName: "Name",
Expand All @@ -133,7 +142,7 @@ export const IModelGrid = ({
accessToken,
apiOverrides,
iTwinId,
sortOptions,
sortOptions: sort,
searchText,
maxCount,
});
Expand Down Expand Up @@ -213,6 +222,15 @@ export const IModelGrid = ({
}
isLoading={fetchStatus === DataStatus.Fetching}
isSortable
onSort={(state) => {
const columnSort = state.sortBy.find((s) => s.id === "name");
setIsSortOnTable(columnSort?.desc !== undefined);
setSort({
sortType: "name",
descending: columnSort?.desc ?? sortOptions.descending,
});
}}
manualSortBy
onBottomReached={fetchMore}
className="iac-list-structure"
autoResetFilters={false}
Expand Down

0 comments on commit 6818c9a

Please sign in to comment.