fix: prevent z-index from resetting on save when collaborating
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.
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) |
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?
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.