π₯π₯π₯ Open-source Jira, Linear, Monday, and ClickUp alternative. Plane is a modern project management platform to manage tasks, sprints, docs, and triage.
TypeScript boardsbug-trackerdjangodockerganttissue-trackerjirajira-alternativekanbanlinearpostgresqlproduct-managementproject-managementproject-planningpythonreactredistypesciptvitework-management
[WEB-2150] fix: issue selection redirect alert (#5406)
rahulrameshaadf891bcbac5
diff --git a/web/core/hooks/use-multiple-select.ts b/web/core/hooks/use-multiple-select.tsindex 278304c4fe..1e997bbfe1 100644--- a/web/core/hooks/use-multiple-select.ts+++ b/web/core/hooks/use-multiple-select.ts@@ -3,6 +3,8 @@import { useCallback, useEffect, useMemo } from "react";// hooksimport { useMultipleSelectStore } from "@/hooks/store";+//+import useReloadConfirmations from "./use-reload-confirmation";export type TEntityDetails = {entityID: string;@@ -52,6 +54,15 @@ export const useMultipleSelect = (props: Props) => {getEntityDetailsFromEntityID,} = useMultipleSelectStore();+ useReloadConfirmations(+ selectedEntityIds && selectedEntityIds.length > 0,+ "Are you sure you want to leave? Your current bulk operation selections will be lost.",+ true,+ () => {+ clearSelection();+ }+ );+const groups = useMemo(() => Object.keys(entities), [entities]);const entitiesList: TEntityDetails[] = useMemo(diff --git a/web/core/hooks/use-reload-confirmation.tsx b/web/core/hooks/use-reload-confirmation.tsxindex 998c5845d9..6ba324d148 100644--- a/web/core/hooks/use-reload-confirmation.tsx+++ b/web/core/hooks/use-reload-confirmation.tsx@@ -1,8 +1,10 @@import { useCallback, useEffect, useState } from "react";//TODO: remove temp flag isActive later and use showAlert as the source of truth-const useReloadConfirmations = (isActive = true) => {- const [showAlert, setShowAlert] = useState(false);+const useReloadConfirmations = (isActive = true, message?: string, defaultShowAlert = false, onLeave?: () => void) => {+ const [showAlert, setShowAlert] = useState(defaultShowAlert);++ const alertMessage = message ?? "Are you sure you want to leave? Changes you made may not be saved.";const handleBeforeUnload = useCallback((event: BeforeUnloadEvent) => {@@ -28,8 +30,10 @@ const useReloadConfirmations = (isActive = true) => {const isAnchorTargetBlank = anchorElement.getAttribute("target") === "_blank";if (isAnchorTargetBlank) return;// show confirm dialog- const leave = confirm("Are you sure you want to leave? Changes you made may not be saved.");- if (!leave) {+ const isLeaving = confirm(alertMessage);+ if (isLeaving) {+ onLeave && onLeave();+ } else {event.preventDefault();event.stopPropagation();}