Address review: drop a selection that no longer exists after a reload

`renderWithVisibleSelection` kept `state.selectedKey` when it pointed at a node missing from the
freshly loaded graph, so toggling a category or changing the database filter dimmed every node and
left the stale sidebar open. Treat a missing node the same as a hidden one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alexey MilovidovandClaude Opus 5.5 committed 2026-10-11 04:37:01 +00:00
1 parent 3e1b66611e
commit 1c45cfa61c
1 file changed
+5 -4
+5 -4
View File
@@ -2182,12 +2182,13 @@ for (const id of ['url', 'user', 'password']) {
});
}
$('relayout').onclick = render;
/// Redraw after a change of `isNodeVisible`: drop a selection that became hidden, and refresh the
/// highlight and the sidebar of a still-visible selected node, because the redraw recomputes the
/// links of the filtered graph and they must not refer to just-hidden neighbours.
/// Redraw after a change of `isNodeVisible`: drop a selection that became hidden or no longer exists
/// (a reload may have replaced the graph), and refresh the highlight and the sidebar of a still-visible
/// selected node, because the redraw recomputes the links of the filtered graph and they must not
/// refer to just-hidden neighbours.
function renderWithVisibleSelection() {
const selected = state.nodes.get(state.selectedKey);
if (selected && !isNodeVisible(selected)) clearHighlight();
if (!selected || !isNodeVisible(selected)) clearHighlight();
render();
if (state.selectedKey) selectNode(state.selectedKey);
}