Skip to content

Commit

Permalink
Fix empty placeholder showing during loading
Browse files Browse the repository at this point in the history
  • Loading branch information
brionmario committed Oct 22, 2024
1 parent d54b53e commit 52a7fab
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 24 deletions.
25 changes: 2 additions & 23 deletions features/admin.tenants.v1/components/tenant-grid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import CircularProgress from "@oxygen-ui/react/CircularProgress";
import Grid from "@oxygen-ui/react/Grid";
import Typography from "@oxygen-ui/react/Typography";

Check warning on line 22 in features/admin.tenants.v1/components/tenant-grid.tsx

View workflow job for this annotation

GitHub Actions / ⬣ ESLint (STATIC ANALYSIS) (lts/*, 8.7.4)

'Typography' is defined but never used. Allowed unused vars must match /^_/u
import { IdentifiableComponentInterface } from "@wso2is/core/models";
import React, { FunctionComponent, ReactElement, useState } from "react";
import React, { FunctionComponent, ReactElement } from "react";
import { useTranslation } from "react-i18next";
import InfiniteScroll from "react-infinite-scroll-component";
import TenantCard from "./tenant-card";
Expand Down Expand Up @@ -57,18 +57,10 @@ const TenantGrid: FunctionComponent<TenantGridProps> = ({
isInitialRenderingComplete
} = useTenants();

const [ hasMore, setHasMore ] = useState<boolean>(true);

/**
* Handles the load more action in the infinite scroll component.
*/
const handleLoadMore = (): void => {
if (tenantList?.totalResults && tenantListLimit >= tenantList.totalResults) {
setHasMore(false);

return;
}

setTenantListLimit((prevLimit: number) => prevLimit + 10);
};

Expand All @@ -90,20 +82,7 @@ const TenantGrid: FunctionComponent<TenantGridProps> = ({
dataLength={ tenantList?.totalResults ?? 0 }
next={ handleLoadMore }
hasMore={ resolveHasMore() }
loader={
(<Box
display="flex"
alignContent="center"
alignItems="center"
justifyContent="center"
flexDirection="column"
gap={ 2 }
className="infinite-loader"
>
<CircularProgress size={ 22 } className="tenant-list-item-loader" />
<Typography variant="h6">{ t("common:loading") }...</Typography>
</Box>)
}
loader={ null }
endMessage={ null }
>
<WithTenantGridPlaceholders
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ const WithTenantGridPlaceholders: FunctionComponent<WithTenantGridPlaceholdersPr
/>
);

if (!isInitialRenderingComplete && isTenantListLoading) {
if (isTenantListLoading) {
return (
<Grid container spacing={ 3 } data-componentid={ componentId }>
{ renderLoadingPlaceholder() }
Expand Down

0 comments on commit 52a7fab

Please sign in to comment.