Skip to content

Commit ed22017

Browse files
authored
ui: fixed how handles are conditionally hidden/shown (#154)
* ui: fixed how handles are conditionally hidden/shown * ui: better syntax in showHandle function
1 parent c9016f8 commit ed22017

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

lib/ui/outline.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,13 @@ export const OutlineNode: m.Component<Attrs, State> = {
151151
return n.childCount + n.getLinked("Fields").length;
152152
}
153153

154+
const showHandle = () => {
155+
if (node.id === workbench.context?.node?.id || state.hover) {
156+
return true;
157+
}
158+
return node.name.length > 0;
159+
}
160+
154161
return (
155162
<div onmouseover={hover} onmouseout={unhover}>
156163
<div class="node-row-outer-wrapper flex flex-row items-start">
@@ -161,7 +168,7 @@ export const OutlineNode: m.Component<Attrs, State> = {
161168
viewBox="0 0 16 16">
162169
{state.hover && <path style={{transform: "translateY(-1px)"}} fill-rule="evenodd" d="M2.5 12a.5.5 0 0 1 .5-.5h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5zm0-4a.5.5 0 0 1 .5-.5h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5zm0-4a.5.5 0 0 1 .5-.5h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5z" />}
163170
</svg>
164-
<div class="node-handle shrink-0" onclick={toggle} ondblclick={open} oncontextmenu={(e) => workbench.showMenu(e, {node: handleNode, path})} data-menu="node" style={{ display: node.name ? 'block' : 'none' }}>
171+
<div class="node-handle shrink-0" onclick={toggle} ondblclick={open} oncontextmenu={(e) => workbench.showMenu(e, {node: handleNode, path})} data-menu="node" style={{ display: showHandle() ? 'block' : 'none' }}>
165172
{(objectHas(node, "handleIcon"))
166173
? objectCall(node, "handleIcon")
167174
: <svg class="node-bullet" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg">

0 commit comments

Comments
 (0)