Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: failed to render in 1000ms warning #464

Merged
merged 1 commit into from
May 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 21 additions & 7 deletions src/components/GridNoRowsOverlay.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import { LuiStatusSpinner } from "@linzjs/lui";
import { ForwardedRef, forwardRef } from "react";

const GridLoadingOverlayComponent = (props: { headerRowHeight: number }) => (
const GridLoadingOverlayComponentFr = (
props: { headerRowHeight: number },
externalRef: ForwardedRef<HTMLDivElement>,
) => (
<div
ref={externalRef}
style={{
left: 0,
top: 0,
Expand All @@ -19,6 +24,8 @@ const GridLoadingOverlayComponent = (props: { headerRowHeight: number }) => (
</div>
);

const GridLoadingOverlayComponent = forwardRef(GridLoadingOverlayComponentFr);

export interface GridNoRowsOverlayProps {
loading: boolean;
rowCount: number | undefined | null;
Expand All @@ -28,10 +35,17 @@ export interface GridNoRowsOverlayProps {
headerRowHeight: number;
}

export const GridNoRowsOverlay = (props: GridNoRowsOverlayProps) => {
if (props.loading) return <GridLoadingOverlayComponent headerRowHeight={props.headerRowHeight} />;
if (props.rowCount === 0) return <div>{props.noRowsOverlayText ?? "There are currently no rows"}</div>;
if (props.filteredRowCount === 0)
return <div>{props.noRowsMatchingOverlayText ?? "All rows have been filtered"}</div>;
return <span />;
export const GridNoRowsOverlayFr = (props: GridNoRowsOverlayProps, externalRef: ForwardedRef<HTMLDivElement>) => {
if (props.loading) {
return <GridLoadingOverlayComponent ref={externalRef} headerRowHeight={props.headerRowHeight} />;
}
if (props.rowCount === 0) {
return <div ref={externalRef}>{props.noRowsOverlayText ?? "There are currently no rows"}</div>;
}
if (props.filteredRowCount === 0) {
return <div ref={externalRef}>{props.noRowsMatchingOverlayText ?? "All rows have been filtered"}</div>;
}
return <div ref={externalRef} />;
};

export const GridNoRowsOverlay = forwardRef(GridNoRowsOverlayFr);
Loading