Fix page refresh when trying to save custom profile fields (#39828)
This commit is contained in:
parent
fad750b2e6
commit
bee749985a
@ -52,13 +52,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();
|
||||||
@ -66,7 +71,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}>
|
||||||
@ -107,7 +112,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