[WEB-4041] chore: modal outside click behaviour #7072
This commit is contained in:
parent
5b776392bd
commit
6c483fad2f
7 changed files with 41 additions and 18 deletions
|
|
@ -13,6 +13,7 @@ import { CycleForm } from "@/components/cycles";
|
||||||
// constants
|
// constants
|
||||||
// hooks
|
// hooks
|
||||||
import { useEventTracker, useCycle, useProject } from "@/hooks/store";
|
import { useEventTracker, useCycle, useProject } from "@/hooks/store";
|
||||||
|
import useKeypress from "@/hooks/use-keypress";
|
||||||
import useLocalStorage from "@/hooks/use-local-storage";
|
import useLocalStorage from "@/hooks/use-local-storage";
|
||||||
import { usePlatformOS } from "@/hooks/use-platform-os";
|
import { usePlatformOS } from "@/hooks/use-platform-os";
|
||||||
// services
|
// services
|
||||||
|
|
@ -180,8 +181,12 @@ export const CycleCreateUpdateModal: React.FC<CycleModalProps> = (props) => {
|
||||||
setActiveProject(projectId ?? workspaceProjectIds?.[0] ?? null);
|
setActiveProject(projectId ?? workspaceProjectIds?.[0] ?? null);
|
||||||
}, [activeProject, data, projectId, workspaceProjectIds, isOpen]);
|
}, [activeProject, data, projectId, workspaceProjectIds, isOpen]);
|
||||||
|
|
||||||
|
useKeypress("Escape", () => {
|
||||||
|
if (isOpen) handleClose();
|
||||||
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ModalCore isOpen={isOpen} handleClose={handleClose} position={EModalPosition.TOP} width={EModalWidth.XXL}>
|
<ModalCore isOpen={isOpen} position={EModalPosition.TOP} width={EModalWidth.XXL}>
|
||||||
<CycleForm
|
<CycleForm
|
||||||
handleFormSubmit={handleFormSubmit}
|
handleFormSubmit={handleFormSubmit}
|
||||||
handleClose={handleClose}
|
handleClose={handleClose}
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,8 @@ import { FC, useState } from "react";
|
||||||
import { EModalPosition, EModalWidth, ModalCore } from "@plane/ui";
|
import { EModalPosition, EModalWidth, ModalCore } from "@plane/ui";
|
||||||
// components
|
// components
|
||||||
import { InboxIssueCreateRoot } from "@/components/inbox/modals/create-modal";
|
import { InboxIssueCreateRoot } from "@/components/inbox/modals/create-modal";
|
||||||
|
// hooks
|
||||||
|
import useKeypress from "@/hooks/use-keypress";
|
||||||
|
|
||||||
type TInboxIssueCreateModalRoot = {
|
type TInboxIssueCreateModalRoot = {
|
||||||
workspaceSlug: string;
|
workspaceSlug: string;
|
||||||
|
|
@ -20,13 +22,16 @@ export const InboxIssueCreateModalRoot: FC<TInboxIssueCreateModalRoot> = (props)
|
||||||
// handlers
|
// handlers
|
||||||
const handleDuplicateIssueModal = (value: boolean) => setIsDuplicateModalOpen(value);
|
const handleDuplicateIssueModal = (value: boolean) => setIsDuplicateModalOpen(value);
|
||||||
|
|
||||||
|
useKeypress("Escape", () => {
|
||||||
|
if (modalState) {
|
||||||
|
handleModalClose();
|
||||||
|
setIsDuplicateModalOpen(false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ModalCore
|
<ModalCore
|
||||||
isOpen={modalState}
|
isOpen={modalState}
|
||||||
handleClose={() => {
|
|
||||||
handleModalClose();
|
|
||||||
setIsDuplicateModalOpen(false);
|
|
||||||
}}
|
|
||||||
position={EModalPosition.TOP}
|
position={EModalPosition.TOP}
|
||||||
width={isDuplicateModalOpen ? EModalWidth.VIXL : EModalWidth.XXXXL}
|
width={isDuplicateModalOpen ? EModalWidth.VIXL : EModalWidth.XXXXL}
|
||||||
className="!bg-transparent rounded-lg shadow-none transition-[width] ease-linear"
|
className="!bg-transparent rounded-lg shadow-none transition-[width] ease-linear"
|
||||||
|
|
|
||||||
|
|
@ -375,7 +375,6 @@ export const CreateUpdateIssueModalBase: React.FC<IssuesModalProps> = observer((
|
||||||
return (
|
return (
|
||||||
<ModalCore
|
<ModalCore
|
||||||
isOpen={isOpen}
|
isOpen={isOpen}
|
||||||
handleClose={() => handleClose(true)}
|
|
||||||
position={EModalPosition.TOP}
|
position={EModalPosition.TOP}
|
||||||
width={isDuplicateModalOpen ? EModalWidth.VIXL : EModalWidth.XXXXL}
|
width={isDuplicateModalOpen ? EModalWidth.VIXL : EModalWidth.XXXXL}
|
||||||
className="!bg-transparent rounded-lg shadow-none transition-[width] ease-linear"
|
className="!bg-transparent rounded-lg shadow-none transition-[width] ease-linear"
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ import { ModuleForm } from "@/components/modules";
|
||||||
// constants
|
// constants
|
||||||
// hooks
|
// hooks
|
||||||
import { useEventTracker, useModule, useProject } from "@/hooks/store";
|
import { useEventTracker, useModule, useProject } from "@/hooks/store";
|
||||||
|
import useKeypress from "@/hooks/use-keypress";
|
||||||
import { usePlatformOS } from "@/hooks/use-platform-os";
|
import { usePlatformOS } from "@/hooks/use-platform-os";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
|
|
@ -142,8 +143,12 @@ export const CreateUpdateModuleModal: React.FC<Props> = observer((props) => {
|
||||||
setActiveProject(projectId ?? workspaceProjectIds?.[0] ?? null);
|
setActiveProject(projectId ?? workspaceProjectIds?.[0] ?? null);
|
||||||
}, [activeProject, data, projectId, workspaceProjectIds, isOpen]);
|
}, [activeProject, data, projectId, workspaceProjectIds, isOpen]);
|
||||||
|
|
||||||
|
useKeypress("Escape", () => {
|
||||||
|
if (isOpen) handleClose();
|
||||||
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ModalCore isOpen={isOpen} handleClose={handleClose} position={EModalPosition.TOP} width={EModalWidth.XXL}>
|
<ModalCore isOpen={isOpen} position={EModalPosition.TOP} width={EModalWidth.XXL}>
|
||||||
<ModuleForm
|
<ModuleForm
|
||||||
handleFormSubmit={handleFormSubmit}
|
handleFormSubmit={handleFormSubmit}
|
||||||
handleClose={handleClose}
|
handleClose={handleClose}
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,8 @@ import { EModalPosition, EModalWidth, ModalCore } from "@plane/ui";
|
||||||
// helpers
|
// helpers
|
||||||
import { getAssetIdFromUrl } from "@/helpers/file.helper";
|
import { getAssetIdFromUrl } from "@/helpers/file.helper";
|
||||||
import { checkURLValidity } from "@/helpers/string.helper";
|
import { checkURLValidity } from "@/helpers/string.helper";
|
||||||
|
// hooks
|
||||||
|
import useKeypress from "@/hooks/use-keypress";
|
||||||
// plane web components
|
// plane web components
|
||||||
import { CreateProjectForm } from "@/plane-web/components/projects/create/root";
|
import { CreateProjectForm } from "@/plane-web/components/projects/create/root";
|
||||||
// plane web types
|
// plane web types
|
||||||
|
|
@ -54,8 +56,12 @@ export const CreateProjectModal: FC<Props> = (props) => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
useKeypress("Escape", () => {
|
||||||
|
if (isOpen) onClose();
|
||||||
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ModalCore isOpen={isOpen} handleClose={onClose} position={EModalPosition.TOP} width={EModalWidth.XXL}>
|
<ModalCore isOpen={isOpen} position={EModalPosition.TOP} width={EModalWidth.XXL}>
|
||||||
{currentStep === EProjectCreationSteps.CREATE_PROJECT && (
|
{currentStep === EProjectCreationSteps.CREATE_PROJECT && (
|
||||||
<CreateProjectForm
|
<CreateProjectForm
|
||||||
setToFavorite={setToFavorite}
|
setToFavorite={setToFavorite}
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ import { EModalPosition, EModalWidth, ModalCore, TOAST_TYPE, setToast } from "@p
|
||||||
import { ProjectViewForm } from "@/components/views";
|
import { ProjectViewForm } from "@/components/views";
|
||||||
// hooks
|
// hooks
|
||||||
import { useProjectView } from "@/hooks/store";
|
import { useProjectView } from "@/hooks/store";
|
||||||
|
import useKeypress from "@/hooks/use-keypress";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
data?: IProjectView | null;
|
data?: IProjectView | null;
|
||||||
|
|
@ -65,8 +66,12 @@ export const CreateUpdateProjectViewModal: FC<Props> = observer((props) => {
|
||||||
else await handleUpdateView(formData);
|
else await handleUpdateView(formData);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
useKeypress("Escape", () => {
|
||||||
|
if (isOpen) handleClose();
|
||||||
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ModalCore isOpen={isOpen} handleClose={handleClose} position={EModalPosition.TOP} width={EModalWidth.XXL}>
|
<ModalCore isOpen={isOpen} position={EModalPosition.TOP} width={EModalWidth.XXL}>
|
||||||
<ProjectViewForm
|
<ProjectViewForm
|
||||||
data={data}
|
data={data}
|
||||||
handleClose={handleClose}
|
handleClose={handleClose}
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,8 @@ import { IWebhook, IWorkspace, TWebhookEventTypes } from "@plane/types";
|
||||||
import { EModalPosition, EModalWidth, ModalCore, TOAST_TYPE, setToast } from "@plane/ui";
|
import { EModalPosition, EModalWidth, ModalCore, TOAST_TYPE, setToast } from "@plane/ui";
|
||||||
// helpers
|
// helpers
|
||||||
import { csvDownload } from "@/helpers/download.helper";
|
import { csvDownload } from "@/helpers/download.helper";
|
||||||
|
// hooks
|
||||||
|
import useKeypress from "@/hooks/use-keypress";
|
||||||
// components
|
// components
|
||||||
import { WebhookForm } from "./form";
|
import { WebhookForm } from "./form";
|
||||||
import { GeneratedHookDetails } from "./generated-hook-details";
|
import { GeneratedHookDetails } from "./generated-hook-details";
|
||||||
|
|
@ -93,16 +95,12 @@ export const CreateWebhookModal: React.FC<ICreateWebhookModal> = (props) => {
|
||||||
}, 350);
|
}, 350);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
useKeypress("Escape", () => {
|
||||||
|
if (isOpen && !generatedWebhook) handleClose();
|
||||||
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ModalCore
|
<ModalCore isOpen={isOpen} position={EModalPosition.TOP} width={EModalWidth.XXL} className="p-4 pb-0">
|
||||||
isOpen={isOpen}
|
|
||||||
handleClose={() => {
|
|
||||||
if (!generatedWebhook) handleClose();
|
|
||||||
}}
|
|
||||||
position={EModalPosition.TOP}
|
|
||||||
width={EModalWidth.XXL}
|
|
||||||
className="p-4 pb-0"
|
|
||||||
>
|
|
||||||
{!generatedWebhook ? (
|
{!generatedWebhook ? (
|
||||||
<WebhookForm onSubmit={handleCreateWebhook} handleClose={handleClose} />
|
<WebhookForm onSubmit={handleCreateWebhook} handleClose={handleClose} />
|
||||||
) : (
|
) : (
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue