Add tab navigation prevention while in Editable mode
This commit is contained in:
@@ -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"
|
||||||
|
|||||||
Reference in New Issue
Block a user