pass save events differently

This commit is contained in:
Nate Kelley 2025-04-01 15:47:56 -06:00
parent d9bc8d4741
commit dffc3026cd
No known key found for this signature in database
GPG Key ID: FD90372AB8D98B4F
3 changed files with 8 additions and 16 deletions

View File

@ -35,9 +35,7 @@ const SplitterContent: React.FC<{
<PopupSplitter />
<div className="flex items-center space-x-2">
<Button variant={'default'} onClick={onReset}>
Reset
</Button>
<Button onClick={onReset}>Reset</Button>
<Button
className="flex items-center"
variant="black"
@ -58,14 +56,8 @@ const SplitterContent: React.FC<{
title="Unsaved changes"
isDirty={open}
description="Are you sure you want to leave this page?"
onOk={() => {
onSave();
return Promise.resolve();
}}
onCancel={() => {
onReset();
return Promise.resolve();
}}
onOk={onSave}
onCancel={onReset}
/>
</React.Fragment>
);

View File

@ -36,7 +36,7 @@ const sizeVariants = {
};
export const buttonVariants = cva(
'inline-flex items-center overflow-hidden text-base justify-center gap-1.5 shadow rounded transition-all duration-300 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:cursor-not-allowed data-[loading=true]:cursor-progress',
'inline-flex items-center overflow-hidden text-base justify-center gap-1.5 shadow rounded transition-all duration-300 focus-visible:outline-none disabled:pointer-events-none disabled:cursor-not-allowed data-[loading=true]:cursor-progress',
{
variants: {
variant: buttonTypeClasses,

View File

@ -12,9 +12,9 @@ type PreventNavigationProps = {
description: string;
cancelText?: string;
okText?: string;
onOk: () => Promise<void>;
onCancel: () => Promise<void>;
onClose?: () => void;
onOk: (() => Promise<void>) | (() => void);
onCancel: (() => Promise<void>) | (() => void);
onClose?: (() => Promise<void>) | (() => void);
doNotLeavePageOnOkay?: boolean;
};
@ -108,7 +108,7 @@ export const PreventNavigation: React.FC<PreventNavigationProps> = React.memo(
document.querySelectorAll('a').forEach((link) => {
link.addEventListener('click', handleClick);
});
}, 0);
}, 5);
};
setLeavingPage(true);