diff --git a/src/pages/organisationUnits/list/OrganisationUnitList.tsx b/src/pages/organisationUnits/list/OrganisationUnitList.tsx index 5828bf23..58954413 100644 --- a/src/pages/organisationUnits/list/OrganisationUnitList.tsx +++ b/src/pages/organisationUnits/list/OrganisationUnitList.tsx @@ -105,7 +105,12 @@ export const OrganisationUnitList = () => { (column) => column.meta.fieldFilter ) + const { queries, fetchNextPage } = usePaginatedChildrenOrgUnitsController({ + parentIds: parentIdsToLoad, + fieldFilters, + }) const isFiltering = !!identifiableFilter + const hasErrored = queries.some((query) => query.isError) const orgUnitFiltered = useFilteredOrgUnits({ searchQuery: identifiableFilter, @@ -113,11 +118,6 @@ export const OrganisationUnitList = () => { enabled: isFiltering, }) - const { queries, fetchNextPage } = usePaginatedChildrenOrgUnitsController({ - parentIds: parentIdsToLoad, - fieldFilters, - }) - // expand ancestors of the filtered org units useEffect(() => { // reset state when not filtering @@ -265,6 +265,7 @@ export const OrganisationUnitList = () => { } onShowDetailsClick={handleDetailsClick} isFiltering={isFiltering} + hasErrored={hasErrored} fetchNextPage={fetchNextPage} /> ))} diff --git a/src/pages/organisationUnits/list/OrganisationUnitRow.tsx b/src/pages/organisationUnits/list/OrganisationUnitRow.tsx index 46b4b6e1..49b740bc 100644 --- a/src/pages/organisationUnits/list/OrganisationUnitRow.tsx +++ b/src/pages/organisationUnits/list/OrganisationUnitRow.tsx @@ -23,6 +23,7 @@ export const OrganisationUnitRow = ({ isFiltering, fetchNextPage, onShowDetailsClick, + hasErrored, }: { row: Row toggleShowAll: (id: string) => void @@ -30,6 +31,7 @@ export const OrganisationUnitRow = ({ isFiltering: boolean fetchNextPage: (id: string) => void onShowDetailsClick: (model: BaseListModel) => void + hasErrored: boolean }) => { const parentRow = row.getParentRow() @@ -72,7 +74,8 @@ export const OrganisationUnitRow = ({ dataTest="row-expand-icon" loading={ row.getIsExpanded() && - row.subRows.length < 1 + row.subRows.length < 1 && + !hasErrored } icon={ row.getIsExpanded() ? (