Skip to content

Save Theme Preference Using LocalStorage Instead of SessionStorage #92

@martyanovandrey

Description

@martyanovandrey

Currently, the theme preference (light/dark mode) for static documentation is being saved in sessionStorage, causing the user-selected theme to reset when the browser/tab is closed. Instead, we should use localStorage to persist the theme preference across sessions, ensuring a consistent user experience.

Steps to Reproduce:

  1. Change the website theme from the default to another (e.g., from light to dark).
  2. Close the browser or tab.
  3. Reopen the browser or tab and revisit the website.

Expected Behavior:
The website should retain the user's theme preference (light or dark mode) upon reopening the browser.

Actual Behavior:
The theme resets to the default as the preference is stored in sessionStorage.

Proposed Solution:

  • Update the code to store the theme preference in localStorage instead of sessionStorage.
  • Ensure that the theme preference is retrieved from localStorage on page load.

Code Context:

return (sessionStorage.getItem(name) as Settings[T]) || DEFAULT_USER_SETTINGS[name];

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Status

    In progress

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions