Skip to content

Commit

Permalink
Merge pull request #564 from terrestris/sortOverPages
Browse files Browse the repository at this point in the history
fix: corrects sorting over multiple pages
  • Loading branch information
TreffN authored Jun 28, 2024
2 parents 761d32c + 4bda1d5 commit 18ee6d3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ export type GeneralEntityConfigType<T extends BaseEntity> = {
i18n: FormTranslations;
endpoint: string;
entityType: string;
defaultSortField?: string;
entityName?: string;
navigationTitle?: string;
subTitle?: string;
Expand All @@ -128,6 +129,7 @@ export function GeneralEntityRoot<T extends BaseEntity>({
i18n,
endpoint,
entityType,
defaultSortField,
entityName = 'Entität',
navigationTitle = 'Entitäten',
subTitle = '… mit denen man Dinge tun kann (aus Gründen bspw.)',
Expand Down Expand Up @@ -170,11 +172,11 @@ export function GeneralEntityRoot<T extends BaseEntity>({
} = useTranslation();

useEffect(() => {
setPageCurrent(1);
setSortField(defaultSortField? defaultSortField : undefined);
setSortOrder('ascend');
setSortField(undefined);
setPageCurrent(1);
setFiltered(false); // to always obtain pagination when changing the entity
}, [entityType]);
}, [entityType, defaultSortField]);

/**
* Validate form fields
Expand Down
1 change: 1 addition & 0 deletions src/Page/Portal/Portal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ export const Portal: React.FC<PortalProps> = () => {
path={`${entityConfig?.entityType}/*`}
element={
<GeneralEntityRoot
key={entityConfig.entityType}
{...entityConfig}
onEntitiesLoaded={onEntitiesLoaded}
/>
Expand Down

0 comments on commit 18ee6d3

Please sign in to comment.