Skip to content

Orphan chart drawing remains visible and cannot be deleted from CLI package #32

Description

@stan373

Orphan chart drawing remains visible and cannot be deleted

Environment

  • Univer CLI: 0.4.0
  • Viewer: local Collab Gateway Viewer at http://127.0.0.1:9123/
  • Reproduction package: harbourline-q3-qbr-deep-ocean.univer
  • Target Sheet unit: Ct1A0c (Harbourline Q3 QBR)
  • Worksheet: Chart Gallery
  • Diagnostic worktree: wt-mshcgd6y-xpojxs (remove-doc-ghost-chart-frame)

Summary

The CLI package contains stale DRAWING_CHART anchors whose chart resources no longer exist. The Viewer still renders the orphan anchors as selectable chart frames behind an embedded Doc. The chart menu offers Delete chart, but deletion has no effect and the frames return after reload.

Steps to reproduce with the attached file

  1. Unzip harbourline-q3-qbr-orphan-chart-repro.zip.
  2. Open the resulting .univer package in Univer CLI 0.4.0 Viewer.
  3. Open unit Ct1A0c and select the Chart Gallery worksheet.
  4. Select the empty chart frame behind the embedded Doc near rows 5–20.
  5. Open the chart menu and choose Delete chart.
  6. Reload the Viewer.

Actual result

  • The empty chart frame remains visible and selectable.
  • The Viewer identifies it as a chart and continues to offer Delete chart.
  • sheet.charts.remove(orphanDrawingId) returns false.
  • sheet.getDrawingLayout() continues to return the orphan DRAWING_CHART entry.
  • No public generic drawing-removal API is exposed for deleting the orphan independently of the missing chart resource.

Diagnostic evidence

  • Valid chart resources on Chart Gallery: 12.
  • Orphan DRAWING_CHART anchors present in the drawing layout: 13.
  • Three orphan anchors overlap the embedded Doc near row 5.
  • All 12 valid charts retained their source ranges and resolved without diagnostics.
  • Formula errors after recalculation: 0.
  • Key values remained unchanged: $1,140,562 and $1,405,552.
  • The embedded Doc remained present at the same bounds.

Expected result

Choosing Delete chart should remove the selected drawing anchor even if the matching chart resource is already missing.

One of the following would resolve the issue:

  1. Make Delete chart fall back to deleting the orphan drawing anchor.
  2. Detect and clean orphan chart drawings when loading a CLI package.
  3. Expose a public API that removes a Sheet drawing by ID independently of the chart collection.

Temporary workaround

Moving each orphan drawing off-canvas and reducing it to 1 x 1 removes the visible artifact:

sheet.setDrawingPlacement(orphanDrawingId, {
  kind: UniverAPI.Enum.SheetDrawingAnchorType.Position,
  from: {
    row: 0,
    column: 0,
    rowOffset: -1000,
    columnOffset: -1000,
  },
  width: 1,
  height: 1,
});

This only hides the orphan. It does not delete the stale drawing record.

Impact

CLI-generated or edited packages can retain undeletable chart frames that overlap embedded Docs or other floating objects. The UI presents a deletion action that silently cannot complete, leaving the package with persistent orphan drawing records.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions