[Glitch] Fix page refresh when trying to save custom profile fields
Port b40eed5e3c016184784835d522450444edc95d06 to glitch-soc Signed-off-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
parent
ac1a00e0df
commit
0a18cdd556
@ -60,13 +60,18 @@ export const ConfirmationModal: React.FC<
|
|||||||
noCloseOnConfirm = false,
|
noCloseOnConfirm = false,
|
||||||
noFocusButton = false,
|
noFocusButton = false,
|
||||||
}) => {
|
}) => {
|
||||||
const handleClick = useCallback(() => {
|
const handleSubmit = useCallback<React.SubmitEventHandler<HTMLFormElement>>(
|
||||||
if (!noCloseOnConfirm) {
|
(e) => {
|
||||||
onClose();
|
e.preventDefault();
|
||||||
}
|
|
||||||
|
|
||||||
void onConfirm();
|
if (!noCloseOnConfirm) {
|
||||||
}, [onClose, onConfirm, noCloseOnConfirm]);
|
onClose();
|
||||||
|
}
|
||||||
|
|
||||||
|
void onConfirm();
|
||||||
|
},
|
||||||
|
[onClose, onConfirm, noCloseOnConfirm],
|
||||||
|
);
|
||||||
|
|
||||||
const handleSecondary = useCallback(() => {
|
const handleSecondary = useCallback(() => {
|
||||||
onClose();
|
onClose();
|
||||||
@ -74,7 +79,7 @@ export const ConfirmationModal: React.FC<
|
|||||||
}, [onClose, onSecondary]);
|
}, [onClose, onSecondary]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ModalShell onSubmit={handleClick}>
|
<ModalShell onSubmit={handleSubmit}>
|
||||||
<ModalShellBody className={className}>
|
<ModalShellBody className={className}>
|
||||||
{noFocusButton ? (
|
{noFocusButton ? (
|
||||||
<NavigationFocusTarget as='h1' id={titleId}>
|
<NavigationFocusTarget as='h1' id={titleId}>
|
||||||
@ -115,7 +120,6 @@ export const ConfirmationModal: React.FC<
|
|||||||
{/* eslint-disable jsx-a11y/no-autofocus -- we are in a modal and thus autofocusing is justified */}
|
{/* eslint-disable jsx-a11y/no-autofocus -- we are in a modal and thus autofocusing is justified */}
|
||||||
<Button
|
<Button
|
||||||
type='submit'
|
type='submit'
|
||||||
onClick={handleClick}
|
|
||||||
loading={updating}
|
loading={updating}
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
autoFocus={!noFocusButton}
|
autoFocus={!noFocusButton}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user