Skip to content

Commit

Permalink
fix: stop row loaders if there is an error
Browse files Browse the repository at this point in the history
  • Loading branch information
flaminic committed Nov 14, 2024
1 parent 88e5785 commit ec3d921
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
11 changes: 6 additions & 5 deletions src/pages/organisationUnits/list/OrganisationUnitList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,19 +105,19 @@ 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,
fieldFilters,
enabled: isFiltering,
})

const { queries, fetchNextPage } = usePaginatedChildrenOrgUnitsController({
parentIds: parentIdsToLoad,
fieldFilters,
})

// expand ancestors of the filtered org units
useEffect(() => {
// reset state when not filtering
Expand Down Expand Up @@ -265,6 +265,7 @@ export const OrganisationUnitList = () => {
}
onShowDetailsClick={handleDetailsClick}
isFiltering={isFiltering}
hasErrored={hasErrored}
fetchNextPage={fetchNextPage}
/>
))}
Expand Down
5 changes: 4 additions & 1 deletion src/pages/organisationUnits/list/OrganisationUnitRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@ export const OrganisationUnitRow = ({
isFiltering,
fetchNextPage,
onShowDetailsClick,
hasErrored,
}: {
row: Row<OrganisationUnitListItem>
toggleShowAll: (id: string) => void
showAllActive: boolean
isFiltering: boolean
fetchNextPage: (id: string) => void
onShowDetailsClick: (model: BaseListModel) => void
hasErrored: boolean
}) => {
const parentRow = row.getParentRow()

Expand Down Expand Up @@ -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() ? (
Expand Down

0 comments on commit ec3d921

Please sign in to comment.