fix(study-library): stop doc-slide cross-slide bleed + data loss on fast slide-switch - #2117
Open
neerajhariyale wants to merge 3 commits into
Open
fix(study-library): stop doc-slide cross-slide bleed + data loss on fast slide-switch#2117neerajhariyale wants to merge 3 commits into
neerajhariyale wants to merge 3 commits into
Conversation
…itch Shared Yoopta editor is reused across slides; switching fast let the auto-save-on-switch read the live editor after it had loaded the incoming slide, writing one slide's body into the outgoing slide's row (e.g. film 'Lesson 1' overwrote an unrelated 'Document 2'). - Track the slide the editor actually holds (editorLoadedSlideIdRef). - Route both switch-save triggers through decideSwitchSave() (pure, tested): save live only when the editor still holds the outgoing slide, else use that slide's last clean snapshot, else skip -- never persist another slide's content. - Gate all fallback-cache writers against empty/degraded content. - Remove legacy handleUnsavedDocIfNeeded (read live editor w/o guard). - Disable editor autoFocus to stop the Slate mount-focus crash. Adds switchSaveGuard.test.ts (18 cases incl. the prod bleed + fuzz). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Contributor
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 55 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
Deploying frontend-admin-dashboard with
|
| Latest commit: |
c0ca1b3
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://d5ecb3bd.frontend-admin-dashboard.pages.dev |
| Branch Preview URL: | https://fix-doc-slide-rapid-switch-b.frontend-admin-dashboard.pages.dev |
pick() returned T | undefined; assert the in-range index so it types as T. Fixes the admin tsc build failure. Full project tsc now passes (0 errors). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…SYNC) The Yoopta editor instance is shared across slides, so its undo stack survived slide switches. Pressing Cmd+Z on the newly-loaded slide rewound into the PREVIOUS slide's operations (or undid the setEditorValue load), changing the current slide's content and flipping it to UNSYNC. Reset editor.historyStack after every content load so undo is scoped to the current slide's own edits. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The doc-slide editor is one shared Yoopta instance reused across slides. Switching slides fast let the auto-save-on-switch read the live editor after it had already loaded the incoming slide, writing one slide's body into the outgoing slide's DB row.
Confirmed prod case: the film "Lesson 1" content overwrote an unrelated "Document 2" slide (both draft + published), destroying Document 2's own content.
Fix
editorLoadedSlideIdRef— tracks which slide the shared editor actually holds; set synchronously right after everysetEditorValue.decideSwitchSave()(new pure, unit-tested guard) — both switch-save triggers route through it: save the live editor only when it still holds the outgoing slide; else fall back to that slide's last clean snapshot; else skip — never persist another slide's content.handleUnsavedDocIfNeeded(read the live editor without the guard — a latent bleed).autoFocusto stop the Slate mount-focus crash.Tests
switchSaveGuard.test.ts— 18 cases incl. the exact prod bleed, an exhaustive (previous × editorLoaded × cacheOwner) invariant sweep, degraded-never-cached, and a 5000-op fuzz. Verified green against the compiled logic.Deploy note
Data loss on prod continues until this is merged AND the admin dashboard is redeployed.
🤖 Generated with Claude Code