Skip to content

Commit f06f970

Browse files
committed
Fix layout when editing existing node (#12814)
Fixes #12760 The issue is addressed by keeping WidgetPorts rects when starting editing + make minimum width of Component Browser, so no edges will be dangling. https://github.com/user-attachments/assets/cdd4bb70-54e1-4174-85ec-4d2b31892986
1 parent b3c04f4 commit f06f970

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

app/gui/src/project-view/components/ComponentBrowser.vue

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ const COMPONENT_EDITOR_PADDING = NODE_CONTENT_PADDING
4545
const ICON_WIDTH = 24
4646
// Component editor is larger than a typical node, so the edge should touch it a bit higher.
4747
const EDGE_Y_OFFSET = -8
48+
const MIN_WIDTH = 295
4849
4950
const cssComponentEditorPadding = `${COMPONENT_EDITOR_PADDING}px`
5051
@@ -162,6 +163,13 @@ const transform = computed(() => {
162163
return `translate(${x}px, ${y}px)`
163164
})
164165
166+
const minWidth = computed(() => {
167+
if (props.usage.type !== 'editNode') return `${MIN_WIDTH}px`
168+
const rect = graphStore.nodeRects.get(props.usage.node)
169+
if (rect == null) return `${MIN_WIDTH}px`
170+
return `${rect.width * props.navigator.scale}px`
171+
})
172+
165173
// === Selection ===
166174
167175
const selected = ref<Component | null>(null)
@@ -375,7 +383,7 @@ const listsHandler = listBindings.handler({
375383
<div
376384
ref="cbRoot"
377385
class="ComponentBrowser"
378-
:style="{ transform }"
386+
:style="{ transform, minWidth }"
379387
:data-self-argument="input.selfArgument"
380388
tabindex="-1"
381389
@focusout="handleDefocus"
@@ -443,7 +451,6 @@ const listsHandler = listBindings.handler({
443451
--radius-default: 20px;
444452
--background-color: #fff;
445453
--doc-panel-bottom-clip: 4px;
446-
min-width: 295px;
447454
width: min-content;
448455
color: rgba(0, 0, 0, 0.6);
449456
font-size: 11.5px;

app/gui/src/project-view/components/GraphEditor/GraphNode.vue

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,7 @@ const nodeClass = computed(() => {
430430
outputNode: props.node.type === 'output',
431431
menuVisible: menuVisible.value,
432432
menuFull: menuFull.value,
433+
edited: props.edited,
433434
}
434435
})
435436
@@ -489,7 +490,6 @@ onWindowBlur(() => {
489490

490491
<template>
491492
<div
492-
v-show="!edited"
493493
ref="rootNode"
494494
class="GraphNode define-node-colors"
495495
:style="nodeStyle"
@@ -730,4 +730,10 @@ onWindowBlur(() => {
730730
.dragged {
731731
cursor: grabbing !important;
732732
}
733+
734+
/* We use this instead of "v-show", because we want the node content being still laid out,
735+
so the edges won't jump. */
736+
.edited {
737+
visibility: hidden;
738+
}
733739
</style>

0 commit comments

Comments
 (0)