diff --git a/src/editor/js/components/editor.tsx b/src/editor/js/components/editor.tsx index f66cdf41fd4df2807561f76420457962e4934808..dc8f96187d677cc6a973b16850367b6f36bfc66d 100644 --- a/src/editor/js/components/editor.tsx +++ b/src/editor/js/components/editor.tsx @@ -305,7 +305,12 @@ export class Editor extends React.PureComponent<propTypes, stateTypes> { } // Draw label - if (this.state.visibleLabels) { + const isNodeRelatedToSelection: boolean = + this.state.selectedNode === undefined || + this.isHighlighted(node) || + this.state.selectedNode.neighbors.includes(node); + + if (this.state.visibleLabels && isNodeRelatedToSelection) { const label = node.label; const fontSize = 11 / globalScale; ctx.font = `${fontSize}px Sans-Serif`;