Skip to content

Add timeout prop to loading components #10836

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

Open
wants to merge 1 commit into
base: next
Choose a base branch
from
Open
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ export const SimpleListLoading = (inProps: SimpleListLoadingProps) => {
hasSecondaryText,
hasTertiaryText,
nbFakeLines = 5,
timeout = 1000,
...rest
} = props;

const oneSecondHasPassed = useTimeout(1000);
const oneSecondHasPassed = useTimeout(timeout);

return oneSecondHasPassed ? (
<StyledList className={className} {...rest}>
Expand Down Expand Up @@ -109,6 +110,7 @@ export interface SimpleListLoadingProps extends ListProps {
hasSecondaryText?: boolean;
hasTertiaryText?: boolean;
nbFakeLines?: number;
timeout?: number;
}

declare module '@mui/material/styles' {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ const DatagridLoading = ({
nbChildren,
nbFakeLines = 5,
size,
timeout = 1000,
}: DatagridLoadingProps) => {
const oneSecondHasPassed = useTimeout(1000);
const oneSecondHasPassed = useTimeout(timeout);
if (!oneSecondHasPassed) return null;
return (
<div className={DatagridClasses.root}>
Expand Down Expand Up @@ -128,6 +129,7 @@ export interface DatagridLoadingProps {
nbChildren: number;
nbFakeLines?: number;
size?: 'small' | 'medium';
timeout?: number;
}

export default memo(DatagridLoading);
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ export const DataTableLoading = memo(function DataTableLoading({
nbChildren,
nbFakeLines = 5,
size,
timeout = 1000,
}: DataTableLoadingProps) {
const oneSecondHasPassed = useTimeout(1000);
const oneSecondHasPassed = useTimeout(timeout);
if (!oneSecondHasPassed) return null;
return (
<div className={DataTableClasses.root}>
Expand Down Expand Up @@ -128,4 +129,5 @@ export interface DataTableLoadingProps<RecordType extends RaRecord = any> {
nbChildren: number;
nbFakeLines?: number;
size?: 'small' | 'medium';
timeout?: number;
}
Loading