Skip to content

Commit

Permalink
fix: prevent page hotkeys firing with opened YTDialog [#768]
Browse files Browse the repository at this point in the history
  • Loading branch information
vrozaev committed Feb 12, 2025
1 parent 233e945 commit 1e6d097
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions packages/ui/src/ui/components/Dialog/Dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ import {TimeDuration} from '../../components/TimeDuration/TimeDuration';
import {DatePickerControl} from './controls/DatePickerControl/DatePickerControl';
import {RangeInputPickerControl} from './controls/RangeInputPickerControl/RangeInputPickerControl';
import {AclColumnsControl} from '../../containers/ACL/RequestPermissions/AclColumnsControl/AclColumnsControl';
import {useHotkeysScope} from '../../hooks/use-hotkeysjs-scope';

const block = cn('yt-dialog');

Expand Down Expand Up @@ -214,10 +215,15 @@ export function YTDialog<Values, InitialValues = Partial<Values>>(
InitialValues,
DialogTabField<DialogField<Values>>,
DialogField<Values>
> & {asLeftTopBlock?: boolean},
> & {hotkeyScope?: string; asLeftTopBlock?: boolean},
) {
const {modal, asLeftTopBlock, headerProps} = props;
const {modal, asLeftTopBlock, headerProps, hotkeyScope = 'yt-dialog'} = props;
const dialog = <DFDialog {...(props as any)} modal={asLeftTopBlock ? false : modal} />;

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

return asLeftTopBlock ? (
<div className={block('as-block', {['has-header']: Boolean(headerProps)})}>{dialog}</div>
) : (
Expand Down

0 comments on commit 1e6d097

Please sign in to comment.