fix: admin/options: save button is ignored sometimes #281

Massimo Melina committed Jul 3, 2023 at 18:35 UTC 7e871b38d96c13ed9f22569edc5e7cb929b50e84
1 file changed +2 -1
mui-grid-form/index.ts
+2 -1
@@ -19,6 +19,7 @@ import { LoadingButton } from '@mui/lab'
19 import * as _ from 'lodash'
20 import { StringField } from './StringField'
21 import { GridProps } from '@mui/material/Grid/Grid'
22 +import { useDebounce } from 'usehooks-ts'
23 export * from './SelectField'
24 export * from './misc-fields'
25 export * from './StringStringField'
@@ -199,7 +200,7 @@ export function Form<Values extends Dict>({
200 variant: 'contained',
201 startIcon: h(Save),
202 children: "Save",
202 - loading: phase !== Phase.Idle,
203 + loading: useDebounce(phase !== Phase.Idle), // debounce fixes click being ignored at state change, and flickering
204 ...saveBtn,
205 onClick: pleaseSubmit,
206 }),