Repository navigation
fix: guard localStorage access and export a safeStorage helper - #20
Merged
Merged
Conversation
TablePagination called localStorage.setItem unguarded, so changing the page size threw in browsers that block or disable storage (e.g. LibreWolf with site data blocked, dom.storage.enabled=false, quota exceeded) and the page never reset to 0. Add safeStorage (get/set/remove) that falls back to "nothing stored" on any failure, use it in TablePagination and the language context, and export it so downstream libraries can use it too. An ESLint rule now forbids direct localStorage/sessionStorage access outside the helper. Closes #19 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 17, 2026
Merged
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.
Closes #19
What
safeStoragehelper (src/lib/safe-storage.ts) withget,setandremove. Every failure (storage missing, access throwing, quota exceeded) falls back to "nothing stored" instead of throwing.TablePaginationuses it when it persists the page size. Before, an unguardedlocalStorage.setItemthrew insideonValueChange, soonPageChange(0)never ran.LanguageProvideruses it instead of its owntry/catchblocks.safeStorageis exported from the package entry point so@open-elements/nextjs-app-layerand apps can use it.localStorage/sessionStorageaccess (no-restricted-globals,no-restricted-properties) outside the helper and tests.Why
Browsers with strict privacy settings, such as LibreWolf with site data blocked or
dom.storage.enabled = false, throw on storage access or have nolocalStorageat all.Tests
safe-storage.test.tscovers normal use, a storage that throws on every call,localStorage === null, and thelocalStoragegetter itself throwing.table-pagination.test.tsxadds two page-size change tests. The storage-throws test fails without the fix.lint,typecheck,format:check,test(184 tests) andbuildpass locally.🤖 Generated with Claude Code