Skip to content

Commit

Permalink
chore: introduced ModalWrapper, now we use it instead of Modal from u…
Browse files Browse the repository at this point in the history
…ikit [#768]
  • Loading branch information
vrozaev committed Feb 12, 2025
1 parent 00edc19 commit d89a48a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/ui/src/ui/components/Modal/Modal.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, {Component} from 'react';
import block from 'bem-cn-lite';

import {Modal as ModalImpl} from '@gravity-ui/uikit';
import {ModalWrapper as ModalImpl} from '../ModalWrapper/ModalWrapper';
import Icon from '../Icon/Icon';

import withHandledScrollBar from '../../hocs/components/Modal/withHandledScrollBar';
Expand Down
3 changes: 2 additions & 1 deletion packages/ui/src/ui/components/Modal/SimpleModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import block from 'bem-cn-lite';

import Icon from '../Icon/Icon';

import {Button, Loader, Modal as ModalImpl} from '@gravity-ui/uikit';
import {Button, Loader} from '@gravity-ui/uikit';
import {ModalWrapper as ModalImpl} from '../ModalWrapper/ModalWrapper';

import withHandledScrollBar from '../../hocs/components/Modal/withHandledScrollBar';

Expand Down
16 changes: 16 additions & 0 deletions packages/ui/src/ui/components/ModalWrapper/ModalWrapper.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import React from 'react';
// eslint-disable-next-line no-restricted-imports
import {Modal, ModalProps} from '@gravity-ui/uikit';
import {useHotkeysScope} from '../../hooks/use-hotkeysjs-scope';

type ModalWrapperProps = ModalProps & {hotkeyScope?: string};

export const ModalWrapper: React.FC<ModalWrapperProps> = (props) => {
const {hotkeyScope = 'yt-modal', ...restProps} = props;

// We don't want to trigger any page hotkeys when modal is visible,
// therefore we switing to dialog hotkeys scope.
useHotkeysScope(hotkeyScope, Boolean(restProps.open));

return <Modal {...restProps} />;
};

0 comments on commit d89a48a

Please sign in to comment.