Skip to content

Fix annotation bugs in preview players#2013

Open
NicoPennec wants to merge 8 commits into
cgwire:mainfrom
NicoPennec:main
Open

Fix annotation bugs in preview players#2013
NicoPennec wants to merge 8 commits into
cgwire:mainfrom
NicoPennec:main

Conversation

@NicoPennec
Copy link
Copy Markdown
Member

Problem

Multiple bugs in the preview annotation undo/redo mechanics: state shared across instances, side-effect pushes polluting the stack, stale fabric.Object refs after fullscreen exit, double additions payload, lost positions on ActiveSelection delete.

Solution

  • per-instance undo stacks and silent-mode flag
  • snapshot/restore around addObject/deleteObject in undo/redo
  • markRaw on annotation save payloads
  • resolve action targets by ID from the live canvas
  • pass DOM elements to fabric.Canvas (avoid id collisions)
  • drop redundant addToAdditions on 'remove' undo
  • discardActiveObject before deleting an ActiveSelection
  • add unit tests covering the undo/redo invariants

The undo stacks, silent-mode flag and save buffers were stored on
$options, shared by all instances of a given component — causing
silent strokes loss and mixed history when multiple players co-exist
(e.g. ProductionNewsFeed v-for). Also fixes the silentAnnnotation typo.
deleteObject/addObject push their own entries on doneActionStack (directly, or via fabric's 'object:added' event), so undo left phantom entries — especially on grouped selections where N items were pushed but only one popped. Snapshot the stack length before the call and restore it after, and drop the redundant addToDeletions.
Wrap annotatedPreview and changesToSave with markRaw, for consistency with the doneActionStack/undoneActionStack treatment.
onFullScreenChange recreates fabric.Object instances; resolve undo/redo targets by id from the live canvas so the stack keeps operating on the current objects.
Pass the canvas DOM elements via $refs instead of the id string to avoid collisions when several PreviewPlayer instances share the default id.
ActiveSelection children carry left/top relative to its center.
discardActiveObject() before the loop restores absolute coords.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant