Skip to content

Commit

Permalink
fix: nested components cause confusing hiding
Browse files Browse the repository at this point in the history
e.g.: if solution -has-> component1 -has-> component2, and
solution -has-> component2, both solution "has" edges will be hidden.

it's hard to determine properly when these component edges should be
hidden. probably not worth keeping them around long-term, but
just adding a hack now with a TODO to maybe
remove later in favor of #434.
  • Loading branch information
keyserj committed Aug 4, 2024
1 parent feb9495 commit 6fba48a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/web/topic/store/createDeleteActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,11 @@ const createEdgesImpliedByComposition = (
child: Node,
relation: Relation,
) => {
// creating nodes that are composed of other nodes is complex, and doesn't seem worth trying to manage (i.e. hide)
// TODO?: this complexity makes me think it's not worth trying to create composed edges at all, and
// that #434 is a better solution to the issue of showing connections when nodes are hidden
if (relation.name === "has") return;

const nodesComposedByParent = getNodesComposedBy(parent, topicGraph);
nodesComposedByParent
.filter((composedNode) => composedNode.id != child.id)
Expand Down
9 changes: 7 additions & 2 deletions src/web/topic/utils/edge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,10 +290,15 @@ export const isEdgeAShortcut = (edge: Edge, topicGraph: Graph) => {
* can still be shown when a component node is hidden
*/
export const isEdgeImpliedByComposition = (edge: Edge, topicGraph: Graph) => {
// hiding nodes composed by composed nodes is really complex, let's not bother
// TODO?: this complexity makes me think it's not worth trying to hide composed edges at all, and
// that #434 is a better solution to the issue of showing connections when nodes are hidden
if (edge.label === "has") return false;

const edgeParent = parentNode(edge, topicGraph.nodes);
const edgeChild = childNode(edge, topicGraph.nodes);

// check implied through parent
// check implied through parent, i.e. child -[X]-> component, child -[X]-> parent, and parent -has-> component
const componentsOfParent = components(edgeParent, topicGraph);
const impliedThroughParentComponent = componentsOfParent.some((component) => {
return topicGraph.edges.some(
Expand All @@ -306,7 +311,7 @@ export const isEdgeImpliedByComposition = (edge: Edge, topicGraph: Graph) => {

if (impliedThroughParentComponent) return true;

// check implied through child
// check implied through child, i.e. child -has-> component, component -[X]-> parent, child -[X]-> parent
const componentsOfChild = components(edgeChild, topicGraph);
const impliedThroughChildComponent = componentsOfChild.some((component) => {
return topicGraph.edges.some(
Expand Down

0 comments on commit 6fba48a

Please sign in to comment.