nova-flexible-content icon indicating copy to clipboard operation
nova-flexible-content copied to clipboard

Cookie to remember the status of Block

Open marcelosantos89 opened this issue 4 years ago • 5 comments

When a page has many blocks and we minimize some it could remember the status and the next time we open it would stay minimized. Not sure if it's something that anyone else would use.

marcelosantos89 avatar May 12 '22 09:05 marcelosantos89

I've made a fork of this package and fixed this like this: https://github.com/adaptivemedia/nova-flexible-content/commit/2ff628a5a48a880f47a952b79c70529e6b548082 to use in a private package of ours.

Would be rather easy to make a PR of this but I'm afraid it wouldn't get merged since no PRs have been merged since april and this the maintainer of this package seems quite inactive...

viirre avatar Jun 16 '22 07:06 viirre

@viirre that's a good solutions, thanks for sharing.

marcelosantos89 avatar Jun 19 '22 23:06 marcelosantos89

Using LocalStorage for this feature seems to be the right way to go, indeed. @viirre feel free to make a PR, since this is a simple one it will get merged in easily. Just remove the commented console.log statements and we're good to go.

If you have a minute, I would however prefer the following syntax for the mounted method since it will improve readability for future contributors :

mounted() {
    if(this.isCollapsed()) this.collapse();
}

// ... methods :

isCollapsed() {
    return (localStorage.getItem(this.getCollapsedKey()) === "true");
}

Thanks, and great idea !

toonvandenbos avatar Jun 20 '22 10:06 toonvandenbos

Hmm, what happened to this PR?

This would be a really useful feature - it is very irritating to see all those sections reopen after each update. (Otherwise this is a really nice an useful lib, years ahead of Nova provided fields)

piotrku avatar Jan 22 '24 21:01 piotrku

@piotrku I don't use this package anymore so pretty hard for me to test that this would still work with the latest version, but anymore can feel free to make a PR and submit it (you can find the code in my link above).

viirre avatar Jan 23 '24 06:01 viirre