Skip to content

Add support for disabling local storage usage #2872

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

jsmith2-coveo
Copy link
Contributor

@jsmith2-coveo jsmith2-coveo commented Feb 25, 2025

Changes


Introduces ability to toggle usage of local storage from components and settings elements through dataset functionality of document similar to that of theme. UI checkbox added to settings menu that defaults to being hidden to allow for toggle of this feature via UI, otherwise accomplished through changes to the document.documentElement.dataset attributes directly.

Rationale Behind Changes:


Certain functional cookie requirements require that local storage not be used for legal compliance reasons. As such, having the ability to toggle the use of local storage for components based on users' cookie preferences is a priority.

@jsmith2-coveo jsmith2-coveo marked this pull request as ready for review February 26, 2025 00:15
Comment on lines 32 to 34
if (!this.disableStorage) {
storage.setItem(this.key, open.toString());
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm really not a fan of how this option has propagated to every instance of saving something to storage. A better implementation would instead be to have the storage module perform the correct action based on whether the option was set or not, so this option doesn't leak into every instance of saving state.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I refactored the approach, instead moving everything under the storage utility, making use of a noOpStorageImpl to perform the actions when local storage is disabled.

@phoneticallySAARTHaK
Copy link
Contributor

Certain functional cookie requirements require that local storage not be used for legal compliance reasons. As such, having the ability to toggle the use of local storage for components based on users' cookie preferences is a priority.

Is there a source for this? As per my (limited) knowledge, cookie preferences privacy concerns are for user tracking, I'm not sure if saving component state comes under that.

I'm also not sure if all websites must have a consent form or similar regardless of its use.

@jsmith2-coveo
Copy link
Contributor Author

Saving of component toggle state, and theme via local storage would fall under functional cookie requirements, further details for which can be found here.

image

@Gerrit0 Gerrit0 changed the base branch from master to beta March 1, 2025 15:51
@Gerrit0 Gerrit0 merged commit 70a0d92 into TypeStrong:beta Mar 1, 2025
8 checks passed
@Gerrit0
Copy link
Collaborator

Gerrit0 commented Mar 1, 2025

Thanks! I appreciate the minimal implementation

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.

4 participants