Add tab navigation prevention while in Editable mode

This commit is contained in:
Daniel S. Hansen
2025-07-29 11:51:33 -07:00
parent 89c32e4f6e
commit a06a79218c
2 changed files with 14 additions and 2 deletions
@@ -16,7 +16,7 @@ export default function Canvas({ view, setView, layout, setLayout, onLayoutChang
return ( return (
<Box height="100%" width="100%"> <Box height="100%" width="100%">
{/* {view === "widget" && */} {/* Check if view is a tab inside the Canvas Header */}
{ DASHBOARD_VIEWS.includes(view) && ( { DASHBOARD_VIEWS.includes(view) && (
<DashboardCanvas <DashboardCanvas
view={ view } view={ view }
@@ -86,8 +86,20 @@ export function DashboardCanvas({ view, setView, layout, setLayout, onLayoutChan
// defaultValue="widget" // defaultValue="widget"
value={ view } value={ view }
// onValueChange={ setView } // onValueChange={ setView }
onValueChange={(e) => setView(e.value)}
// onValueChange={(value) => setView(value)} // onValueChange={(value) => setView(value)}
// onValueChange={(e) => setView(e.value)}
onValueChange={(e) => {
const nextView = e.value;
if (view === "widget" && isEditable && nextView !== "widget") {
const confirmed = window.confirm(
"You have unsaved changes. Do you wish to discard them and continue?"
);
if (!confirmed) return;
onCancel();
}
setView(nextView);
}}
> >
<Flex <Flex
as="header" as="header"