excalidraw icon indicating copy to clipboard operation
excalidraw copied to clipboard

fix: prevent z-index from resetting on save when collaborating

Open Periclod opened this issue 3 years ago • 1 comments

When using the collaboration feature and using for example bring to front, it would reset the next time it auto-saves.

The issue seems to be that the reconciliation algorithm falsely assumes the first (lower z-index) element is a duplicate and removes it. It does that because the displaced elements in zIndex.ts, while changed, don't receive a version bump.

Periclod avatar Sep 09 '22 08:09 Periclod

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
excalidraw ✅ Ready (Inspect) Visit Preview Sep 12, 2022 at 0:31AM (UTC)
excalidraw-package-example ✅ Ready (Inspect) Visit Preview Sep 12, 2022 at 0:31AM (UTC)
1 Ignored Deployment
Name Status Preview Updated
docs ⬜️ Ignored (Inspect) Sep 12, 2022 at 0:31AM (UTC)

vercel[bot] avatar Sep 09 '22 08:09 vercel[bot]

Hi, sorry for completely missing this PR! I haven't reviewed the code so can't say whether what this is fixing is legit or not. But we've just merged https://github.com/excalidraw/excalidraw/pull/5742 which fixes seemingly the same issue? At least I couldn't reproduce anything on that fix. It's in production now (make sure the app reloads to latest). Can you check if it reproduces there?

dwelle avatar Oct 08 '22 19:10 dwelle

Looks like this PR is focused solely on z-index actions (Send forward, Bring backward, etc..).

But it seems like there is another bug in reconciliation logic, which moves an element spliced somewhere in the middle of Scene.elements to the end. See this comment for more details It was hard to reproduce because it happens at full scene sync interval, which is every 20 seconds right now. If you set SYNC_FULL_SCENE_INTERVAL_MS to a short duration (like 1s), the issue becomes much more apparent.

josephbuchma avatar Oct 09 '22 04:10 josephbuchma