mirror of
https://github.com/invoke-ai/InvokeAI.git
synced 2026-02-19 09:54:24 -05:00
feat(ui): abstract out the global menu close trigger
This logic is moved into a hook. This is needed for our context menus to close when the user clicks something in reactflow. It needed to be extended to support menus also.
This commit is contained in:
@@ -4,7 +4,7 @@ import { stateSelector } from 'app/store/store';
|
||||
import { useAppDispatch, useAppSelector } from 'app/store/storeHooks';
|
||||
import { defaultSelectorOptions } from 'app/store/util/defaultMemoizeOptions';
|
||||
import { $flow } from 'features/nodes/store/reactFlowInstance';
|
||||
import { contextMenusClosed } from 'features/ui/store/uiSlice';
|
||||
import { bumpGlobalMenuCloseTrigger } from 'features/ui/store/uiSlice';
|
||||
import { MouseEvent, useCallback, useRef } from 'react';
|
||||
import { useHotkeys } from 'react-hotkeys-hook';
|
||||
import {
|
||||
@@ -153,7 +153,7 @@ export const Flow = () => {
|
||||
);
|
||||
|
||||
const handlePaneClick = useCallback(() => {
|
||||
dispatch(contextMenusClosed());
|
||||
dispatch(bumpGlobalMenuCloseTrigger());
|
||||
}, [dispatch]);
|
||||
|
||||
const onInit: OnInit = useCallback((flow) => {
|
||||
|
||||
@@ -15,7 +15,7 @@ import {
|
||||
NODE_WIDTH,
|
||||
} from 'features/nodes/types/constants';
|
||||
import { zNodeStatus } from 'features/nodes/types/invocation';
|
||||
import { contextMenusClosed } from 'features/ui/store/uiSlice';
|
||||
import { bumpGlobalMenuCloseTrigger } from 'features/ui/store/uiSlice';
|
||||
import {
|
||||
MouseEvent,
|
||||
PropsWithChildren,
|
||||
@@ -70,7 +70,7 @@ const NodeWrapper = (props: NodeWrapperProps) => {
|
||||
if (!e.ctrlKey && !e.altKey && !e.metaKey && !e.shiftKey) {
|
||||
dispatch(nodeExclusivelySelected(nodeId));
|
||||
}
|
||||
dispatch(contextMenusClosed());
|
||||
dispatch(bumpGlobalMenuCloseTrigger());
|
||||
},
|
||||
[dispatch, nodeId]
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user