fix: workflow fixview padding & context menu position (#6169)

This commit is contained in:
heheer
2025-12-30 21:22:03 +08:00
committed by GitHub
parent f626c961fb
commit f8bedc1209
9 changed files with 13 additions and 24 deletions

View File

@@ -262,7 +262,7 @@ export const iconPaths = {
'core/dataset/yuqueDatasetColor': () => import('./icons/core/dataset/yuqueDatasetColor.svg'),
'core/dataset/yuqueDatasetOutline': () => import('./icons/core/dataset/yuqueDatasetOutline.svg'),
'core/modules/basicNode': () => import('./icons/core/modules/basicNode.svg'),
'core/modules/fixview': () => import('./icons/core/modules/fixview.svg'),
'core/modules/fitView': () => import('./icons/core/modules/fitView.svg'),
'core/modules/flowLight': () => import('./icons/core/modules/flowLight.svg'),
'core/modules/previewLight': () => import('./icons/core/modules/previewLight.svg'),
'core/modules/systemPlugin': () => import('./icons/core/modules/systemPlugin.svg'),

View File

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

View File

@@ -64,7 +64,7 @@ const SearchButton = (props: ButtonProps) => {
const searchedNode = searchResult[searchIndex] ?? searchResult[0];
if (searchedNode) {
fitView({ nodes: [searchedNode], padding: 0.4 });
fitView({ nodes: [searchedNode], padding: 0.6 });
}
return nodes.map((node) => ({

View File

@@ -226,7 +226,7 @@ const ContextMenu = () => {
});
setTimeout(() => {
fitView();
fitView({ padding: 0.3 });
});
}, [fitView, getParentNodeSizeAndPosition, setEdges, setNodes]);
@@ -302,9 +302,9 @@ const ContextMenu = () => {
);
return (
<Box position="relative">
<Box>
<Box
position="absolute"
position={'fixed'}
top={`${menu.top - 6}px`}
left={`${menu.left + 10}px`}
width={0}
@@ -312,18 +312,17 @@ const ContextMenu = () => {
borderLeft="6px solid transparent"
borderRight="6px solid transparent"
borderBottom="6px solid white"
zIndex={2}
zIndex={10}
filter="drop-shadow(0px -1px 2px rgba(0, 0, 0, 0.1))"
/>
<Box
position={'absolute'}
position={'fixed'}
top={menu.top}
left={menu.left}
bg={'white'}
w={'120px'}
rounded={'md'}
boxShadow={'0px 2px 4px 0px #A1A7B340'}
className="context-menu"
color={'myGray.600'}
p={1}
zIndex={10}

View File

@@ -197,11 +197,11 @@ const FlowController = React.memo(function FlowController() {
{/* fit view */}
<MyTooltip label={t('common:page_center')}>
<ControlButton
onClick={() => fitView()}
onClick={() => fitView({ padding: 0.3 })}
style={buttonStyle}
className={`custom-workflow-fix_view ${styles.customControlButton}`}
>
<MyIcon name={'core/modules/fixview'} />
<MyIcon name={'core/modules/fitView'} />
</ControlButton>
</MyTooltip>
</Panel>

View File

@@ -828,7 +828,7 @@ export const useWorkflow = () => {
e.preventDefault();
setMenu({
top: e.clientY - 64,
top: e.clientY + 6,
left: e.clientX - 12
});
},

View File

@@ -135,6 +135,7 @@ const Workflow = () => {
<ReactFlow
ref={reactFlowWrapperCallback}
fitView
fitViewOptions={{ padding: 0.3 }}
nodes={nodes}
edges={edges}
minZoom={minZoom}

View File

@@ -135,8 +135,7 @@ const NodeCard = (props: Props) => {
setTimeout(() => {
fitView({
nodes: [{ id: nodeId }],
padding: 0.3,
duration: 300
padding: 0.3
});
}, 100);
}, [onChangeNode, setPresentationMode, fitView, nodeId]);

View File

@@ -196,19 +196,9 @@ export const WorkflowUtilsProvider = ({ children }: { children: ReactNode }) =>
// View move to the node that failed
fitView({
nodes: nodes.filter((node) => checkResults.includes(node.data.nodeId)),
padding: 0.3,
duration: 300
padding: 0.3
});
setTimeout(() => {
const viewport = getViewport();
setViewport({
x: viewport.x,
y: viewport.y + 36,
zoom: viewport.zoom
});
}, 300);
toast({
status: 'warning',
title: t('common:core.workflow.Check Failed')