Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(chat): fix modals outside click (Issue #2578) #2656

Open
wants to merge 12 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions apps/chat/src/components/Chat/Publish/PublishWizard.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { UseDismissProps } from '@floating-ui/react';
import { IconPlus, IconX } from '@tabler/icons-react';
import {
ClipboardEvent,
Expand Down Expand Up @@ -68,6 +69,11 @@ import isEqual from 'lodash-es/isEqual';
import startCase from 'lodash-es/startCase';
import toLower from 'lodash-es/toLower';

const modalDismissProps = {
outsidePress: false,
escapeKey: false,
} as UseDismissProps;
Derikyan marked this conversation as resolved.
Show resolved Hide resolved

interface Props<
T extends Conversation | ShareEntity | PublishRequestDialAIEntityModel,
> {
Expand Down Expand Up @@ -451,6 +457,7 @@ export function PublishModal<
state={isOpen ? ModalState.OPENED : ModalState.CLOSED}
onClose={onClose}
initialFocus={nameInputRef}
dismissProps={modalDismissProps}
>
<div className="flex w-full flex-col divide-y divide-tertiary overflow-y-auto">
<div className="px-3 py-4 md:pl-4 md:pr-10">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { UseDismissProps } from '@floating-ui/react';

import { ModalState } from '@/src/types/modal';

import { ApplicationSelectors } from '@/src/store/application/application.reducers';
Expand All @@ -8,6 +10,11 @@ import Modal from '../../Common/Modal';
import { Spinner } from '../../Common/Spinner';
import { ReviewApplicationDialogView } from './ReviewApplicationDialogView';

const modalDismissProps = {
outsidePress: true,
escapeKey: true,
} as UseDismissProps;

export function ReviewApplicationDialog() {
const isLoading = useAppSelector(
ApplicationSelectors.selectIsApplicationLoading,
Expand All @@ -25,8 +32,8 @@ export function ReviewApplicationDialog() {
onClose={handleClose}
overlayClassName="fixed inset-0 top-[48px]"
state={ModalState.OPENED}
dismissProps={modalDismissProps}
containerClassName="flex flex-col gap-4 sm:w-[600px] w-full"
dismissProps={{ outsidePressEvent: 'mousedown' }}
>
{isLoading ? (
<div className="flex h-[250px] flex-col justify-center">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ import { QuickAppView } from '@/src/components/Common/ApplicationWizard/QuickApp
import Modal from '@/src/components/Common/Modal';
import { Spinner } from '@/src/components/Common/Spinner';

const modalDismissProps = { outsidePressEvent: 'mousedown' } as UseDismissProps;
const modalDismissProps = {
outsidePress: false,
escapeKey: false,
} as UseDismissProps;

interface ApplicationWizardProps {
isOpen: boolean;
onClose: (value: boolean) => void;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,20 @@ export const CodeEditor = ({ sourcesFolderId, setValue }: Props) => {
}
}, [rootFileNames, setValue, sourcesFolderId]);

useEffect(() => {
const handleKeyUp = (event: KeyboardEvent) => {
if (event.key === 'Escape' && isFullScreen) {
setIsFullScreen(false);
}
};

window.addEventListener('keyup', handleKeyUp);

return () => {
window.removeEventListener('keyup', handleKeyUp);
};
}, [isFullScreen]);

const handleUploadFile = useCallback(
(relativePath: string) => {
setUploadFolderId(relativePath);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { UseDismissProps } from '@floating-ui/react';
import { useCallback, useMemo } from 'react';

import { useSearchParams } from 'next/navigation';
Expand All @@ -18,6 +19,8 @@ import { ApplicationDetailsHeader } from './ApplicationHeader';

import { PublishActions } from '@epam/ai-dial-shared';

const modalDismissProps = { outsidePress: true } as UseDismissProps;

interface Props {
isMobileView: boolean;
entity: DialAIEntityModel;
Expand Down Expand Up @@ -80,6 +83,7 @@ const ApplicationDetails = ({
overlayClassName="!z-40"
containerClassName="flex w-full flex-col divide-y divide-tertiary divide-tertiary xl:max-w-[720px] max-w-[700px]"
onClose={onClose}
dismissProps={modalDismissProps}
>
<ApplicationDetailsHeader isMobileView={isMobileView} entity={entity} />
<ApplicationDetailsContent entity={entity} />
Expand Down
4 changes: 4 additions & 0 deletions apps/chat/src/components/Marketplace/ApplicationLogs.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { UseDismissProps } from '@floating-ui/react';
import { IconDownload, IconRefresh } from '@tabler/icons-react';
import React from 'react';

Expand Down Expand Up @@ -115,6 +116,8 @@ const LogsFooter = ({ entityId }: { entityId: string }) => {
);
};

const modalDismissProps = { outsidePress: true } as UseDismissProps;

interface ApplicationLogsProps {
entityId: string;
isOpen: boolean;
Expand All @@ -134,6 +137,7 @@ export const ApplicationLogs = ({
overlayClassName="!z-40"
containerClassName="flex w-full flex-col min-h-[350px] xl:max-w-[820px] max-w-[800px]"
onClose={onClose}
dismissProps={modalDismissProps}
>
<LogsHeader />
<LogsView />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { UseDismissProps } from '@floating-ui/react';
import { IconFileArrowRight, IconTrashX } from '@tabler/icons-react';
import { MouseEventHandler, useCallback } from 'react';

Expand Down Expand Up @@ -32,6 +33,11 @@ import Modal from '../../Common/Modal';

import { PublishActions } from '@epam/ai-dial-shared';

const modalDismissProps = {
outsidePress: true,
escapeKey: true,
} as UseDismissProps;

interface Props {
isOpen: boolean;
onDuplicate?: MouseEventHandler<HTMLButtonElement>;
Expand Down Expand Up @@ -106,6 +112,7 @@ export const PreviewPromptModal = ({
portalId="theme-main"
containerClassName="inline-block w-full overflow-y-auto py-4 md:p-0 align-bottom transition-all xl:max-h-[800px] xl:max-w-[720px] 2xl:max-w-[1000px]"
dataQa="preview-prompt-modal"
dismissProps={modalDismissProps}
headingClassName={classNames(
'px-3 md:p-6',
prompt.publicationInfo?.action === PublishActions.DELETE &&
Expand Down
Loading