Skip to content

fix(cms): persist undo/redo history in sessionStorage#793

Merged
RUKAYAT-CODER merged 1 commit into
rinafcode:mainfrom
AugistineCreates:fix/cmsStore-persist
Jun 27, 2026
Merged

fix(cms): persist undo/redo history in sessionStorage#793
RUKAYAT-CODER merged 1 commit into
rinafcode:mainfrom
AugistineCreates:fix/cmsStore-persist

Conversation

@AugistineCreates

Copy link
Copy Markdown
Contributor

This pr closes #778

Overview:
This PR resolves an issue where the cmsStore undo/redo history was completely lost upon a page refresh within a single session. By introducing the Zustand persist middleware configured with sessionStorage, the history stack now gracefully survives page reloads. This ensures content editors don't lose their ability to undo mistakes after a browser crash or an accidental refresh.

Changes:

  • Added Zustand persist middleware: Wrapped useCMSStore with persist to save the store state.
  • sessionStorage Integration: Configured the storage to use sessionStorage so history is available after page refreshes but properly cleared when the browser tab closes.
  • State Selection: Persisted the course, history, and historyIndex properties via the partialize option.
  • Quota Optimization: Lowered the history limit from 50 to 20 items within setCourse and updateCourse to ensure the stored string length remains well within typical sessionStorage quota limits.
  • Tests Coverage Added: Implemented src/store/cmsStore.test.ts to simulate and assert:
    • Correct persistence of state to sessionStorage.
    • Proper store rehydration, allowing undo functionality after a page refresh.
    • Verification that the history length never exceeds the 20 item limit.

Impacted Files:

  • src/store/cmsStore.ts
  • src/store/cmsStore.test.ts

@drips-wave

drips-wave Bot commented Jun 27, 2026

Copy link
Copy Markdown

@AugistineCreates Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@RUKAYAT-CODER

Copy link
Copy Markdown
Contributor

Thank you for contributing to the project.

@RUKAYAT-CODER RUKAYAT-CODER merged commit 5272ba1 into rinafcode:main Jun 27, 2026
4 checks passed
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.

[Refactor] cmsStore undo/redo history is not persisted — history lost on page refresh

2 participants