Skip to content

4086 prevent canvas reset on paste when fragment is present - #11913

Open
Nyildizzz wants to merge 1 commit into
masterfrom
4086-fix-prevent-canvas-reset-ppt-paste
Open

Nyildizzz wants to merge 1 commit into
masterfrom
4086-fix-prevent-canvas-reset-ppt-paste

Conversation

@Nyildizzz

Copy link
Copy Markdown
Collaborator

How the feature works? / How did you fix the issue?

(Screenshots, videos, or GIFs, if applicable)

The fix is in place. Here's the analysis:

Root cause: In shared.ts::load, after dispatching the paste tool action (when fragment: true), two canvas-resetting operations were unconditionally called:

  1. editor.zoomAccordingContent(parsedStruct) — zooms the canvas to fit the new structure
  2. editor.centerStruct() — physically moves all existing structures to center them in the viewport

Both are wrong for the "Add to Canvas" case because the structure is only attached to the cursor at that point (not yet placed on canvas), so the viewport should stay exactly where the user left it.

Fix: Added !fragment guard to both calls. When fragment: true:

  • zoomAccordingContent is skipped — zoom stays unchanged
  • centerStruct is skipped — existing structures stay in place

Side effects: This also improves Ctrl+V clipboard paste behavior (which also uses fragment: true) — zoomAccordingContent was being called there too (a bug), now it won't change the zoom when the user pastes from clipboard. centerStruct was already protected by isPaste: true for clipboard paste, so that's unchanged.

Check list

  • unit-tests written
  • e2e-tests written
  • documentation updated
  • PR name follows the pattern #1234 – issue name
  • branch name doesn't contain '#'
  • PR is linked with the issue
  • base branch (master or release/xx) is correct
  • task status changed to "Code review"
  • reviewers are notified about the pull request

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.

System srolls global canvas back if we add next structure from PPT file in addition to previously added

1 participant