Skip to content

bug(knowledge-graph): Cytoscape canvas blank after toggling from 3D back to 2D #3400

@mrveiss

Description

@mrveiss

Summary

When toggling from 3D back to 2D in the KnowledgeGraph view, the Cytoscape container renders blank (0×0 or empty). The v-if directive unmounts the Cytoscape container while in 3D mode, and a single nextTick is insufficient for Vue to both commit the DOM change and complete layout before Cytoscape initialises.

Root Cause

toggleViewMode used a single nextTick callback:

// Broken — DOM may not be fully laid out yet
nextTick(() => {
  if (!cy.value && cytoscapeContainer.value) {
    initCytoscape()
  }
  updateCytoscapeElements()
})

The first tick commits the v-if change; the second tick guarantees the container has non-zero dimensions.

Fix

Double nextTick pattern (mirrors the existing refreshGraph implementation in the codebase):

nextTick(() => {
  nextTick(() => {
    if (!cy.value && cytoscapeContainer.value) initCytoscape()
    updateCytoscapeElements()
  })
})

Already fixed in: PR #3372 (fix: code-review issues for 3D view toggle)

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions