From c154718b6cf25560132b66a99c7d6b5ef1959205 Mon Sep 17 00:00:00 2001 From: Jonathan Berger Date: Wed, 12 Mar 2025 17:33:38 +0100 Subject: [PATCH] Fix spinner in action buttons Fixes a FOUC (flash of unstyled content) on page load for the create and update buttons Change-type: patch --- src/components/RJST/Actions/Create.tsx | 19 +++++++++------ src/components/RJST/Actions/Update.tsx | 32 ++++++++++++++++++-------- 2 files changed, 34 insertions(+), 17 deletions(-) diff --git a/src/components/RJST/Actions/Create.tsx b/src/components/RJST/Actions/Create.tsx index 2cafbc83..60f4719f 100644 --- a/src/components/RJST/Actions/Create.tsx +++ b/src/components/RJST/Actions/Create.tsx @@ -10,8 +10,7 @@ import { getCreateDisabledReason } from '../utils'; import { ActionContent, LOADING_DISABLED_REASON } from './ActionContent'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { faMagic } from '@fortawesome/free-solid-svg-icons/faMagic'; -import { Box, Button } from '@mui/material'; -import { Spinner } from '../../Spinner'; +import { Box, Button, CircularProgress } from '@mui/material'; import { useTranslation } from '../../../hooks/useTranslations'; import { Tooltip } from '../../Tooltip'; @@ -91,12 +90,18 @@ export const Create = >({ })); }} > - + {action.title} - + {disabledReason === LOADING_DISABLED_REASON && ( + + )} diff --git a/src/components/RJST/Actions/Update.tsx b/src/components/RJST/Actions/Update.tsx index 986bdab0..cd33e477 100644 --- a/src/components/RJST/Actions/Update.tsx +++ b/src/components/RJST/Actions/Update.tsx @@ -12,10 +12,15 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { faPenToSquare } from '@fortawesome/free-solid-svg-icons/faPenToSquare'; import type { CheckedState } from '../components/Table/utils'; import { useTranslation } from '../../../hooks/useTranslations'; -import { Box, Button, useMediaQuery, useTheme } from '@mui/material'; +import { + Box, + Button, + CircularProgress, + useMediaQuery, + useTheme, +} from '@mui/material'; import type { DropDownButtonProps } from '../../DropDownButton'; import { DropDownButton } from '../../DropDownButton'; -import { Spinner } from '../../Spinner'; import { Tooltip } from '../../Tooltip'; interface UpdateProps> { @@ -101,6 +106,7 @@ export const Update = >({ >({ } > {action.title} - + {disabledActionReason === LOADING_DISABLED_REASON && ( + + )} ), @@ -209,12 +215,18 @@ export const Update = >({ })); }} > - + {action.title} - + {disabledUpdateReason === LOADING_DISABLED_REASON && ( + + )}