Fix hotkey scope when opening command menu (#8258)
Fix hotkey scope when opening command menu
This commit is contained in:
@ -2,10 +2,12 @@ import { useActionMenu } from '@/action-menu/hooks/useActionMenu';
|
|||||||
import { ActionMenuComponentInstanceContext } from '@/action-menu/states/contexts/ActionMenuComponentInstanceContext';
|
import { ActionMenuComponentInstanceContext } from '@/action-menu/states/contexts/ActionMenuComponentInstanceContext';
|
||||||
import { isCommandMenuOpenedState } from '@/command-menu/states/isCommandMenuOpenedState';
|
import { isCommandMenuOpenedState } from '@/command-menu/states/isCommandMenuOpenedState';
|
||||||
import { contextStoreNumberOfSelectedRecordsComponentState } from '@/context-store/states/contextStoreNumberOfSelectedRecordsComponentState';
|
import { contextStoreNumberOfSelectedRecordsComponentState } from '@/context-store/states/contextStoreNumberOfSelectedRecordsComponentState';
|
||||||
|
import { isBottomBarOpenedComponentState } from '@/ui/layout/bottom-bar/states/isBottomBarOpenedComponentState';
|
||||||
import { isDropdownOpenComponentState } from '@/ui/layout/dropdown/states/isDropdownOpenComponentState';
|
import { isDropdownOpenComponentState } from '@/ui/layout/dropdown/states/isDropdownOpenComponentState';
|
||||||
import { useRightDrawer } from '@/ui/layout/right-drawer/hooks/useRightDrawer';
|
import { useRightDrawer } from '@/ui/layout/right-drawer/hooks/useRightDrawer';
|
||||||
import { useAvailableComponentInstanceIdOrThrow } from '@/ui/utilities/state/component-state/hooks/useAvailableComponentInstanceIdOrThrow';
|
import { useAvailableComponentInstanceIdOrThrow } from '@/ui/utilities/state/component-state/hooks/useAvailableComponentInstanceIdOrThrow';
|
||||||
import { useRecoilComponentValueV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentValueV2';
|
import { useRecoilComponentValueV2 } from '@/ui/utilities/state/component-state/hooks/useRecoilComponentValueV2';
|
||||||
|
import { useSetRecoilComponentStateV2 } from '@/ui/utilities/state/component-state/hooks/useSetRecoilComponentStateV2';
|
||||||
import { extractComponentState } from '@/ui/utilities/state/component-state/utils/extractComponentState';
|
import { extractComponentState } from '@/ui/utilities/state/component-state/utils/extractComponentState';
|
||||||
import { useEffect } from 'react';
|
import { useEffect } from 'react';
|
||||||
import { useRecoilValue } from 'recoil';
|
import { useRecoilValue } from 'recoil';
|
||||||
@ -21,6 +23,13 @@ export const RecordIndexActionMenuEffect = () => {
|
|||||||
|
|
||||||
const { openActionBar, closeActionBar } = useActionMenu(actionMenuId);
|
const { openActionBar, closeActionBar } = useActionMenu(actionMenuId);
|
||||||
|
|
||||||
|
// Using closeActionBar here was causing a bug because it goes back to the
|
||||||
|
// previous hotkey scope, and we don't want that here.
|
||||||
|
const setIsBottomBarOpened = useSetRecoilComponentStateV2(
|
||||||
|
isBottomBarOpenedComponentState,
|
||||||
|
`action-bar-${actionMenuId}`,
|
||||||
|
);
|
||||||
|
|
||||||
const isDropdownOpen = useRecoilValue(
|
const isDropdownOpen = useRecoilValue(
|
||||||
extractComponentState(
|
extractComponentState(
|
||||||
isDropdownOpenComponentState,
|
isDropdownOpenComponentState,
|
||||||
@ -50,9 +59,9 @@ export const RecordIndexActionMenuEffect = () => {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (isRightDrawerOpen || isCommandMenuOpened) {
|
if (isRightDrawerOpen || isCommandMenuOpened) {
|
||||||
closeActionBar();
|
setIsBottomBarOpened(false);
|
||||||
}
|
}
|
||||||
}, [closeActionBar, isRightDrawerOpen, isCommandMenuOpened]);
|
}, [isRightDrawerOpen, isCommandMenuOpened, setIsBottomBarOpened]);
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user