[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,
|
||||
noFocusButton = false,
|
||||
}) => {
|
||||
const handleClick = useCallback(() => {
|
||||
const handleSubmit = useCallback<React.SubmitEventHandler<HTMLFormElement>>(
|
||||
(e) => {
|
||||
e.preventDefault();
|
||||
|
||||
if (!noCloseOnConfirm) {
|
||||
onClose();
|
||||
}
|
||||
|
||||
void onConfirm();
|
||||
}, [onClose, onConfirm, noCloseOnConfirm]);
|
||||
},
|
||||
[onClose, onConfirm, noCloseOnConfirm],
|
||||
);
|
||||
|
||||
const handleSecondary = useCallback(() => {
|
||||
onClose();
|
||||
@ -74,7 +79,7 @@ export const ConfirmationModal: React.FC<
|
||||
}, [onClose, onSecondary]);
|
||||
|
||||
return (
|
||||
<ModalShell onSubmit={handleClick}>
|
||||
<ModalShell onSubmit={handleSubmit}>
|
||||
<ModalShellBody className={className}>
|
||||
{noFocusButton ? (
|
||||
<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 */}
|
||||
<Button
|
||||
type='submit'
|
||||
onClick={handleClick}
|
||||
loading={updating}
|
||||
disabled={disabled}
|
||||
autoFocus={!noFocusButton}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user