State: stalled on decision to not implement this. To be reopened when the bug reports / complaints from readers start piling up.
== User Story
As a reader, I would like to have a persistent state for my sidebar, so that I don't have to change the state every time I navigate to a new article.
This task records the finished solution.
== Implementation, demo
For logged-out/unregistered AND logged-in users (by @Demian):
[[ http://patchdemo.wmflabs.org/wikis/b70f4202792d685831e5f957fb5953e1/w/ | DEMO with all header improvements, including drop-down usermenu ]] ([[https://gerrit.wikimedia.org/r/c/mediawiki/skins/Vector/+/589808/31|patch 589808]] + [[https://gerrit.wikimedia.org/r/c/mediawiki/skins/Vector/+/606436/4|patch 606436]])
[[ http://patchdemo.wmflabs.org/wikis/87ff0eb77076404c5541ac861a7eb158/w/ | DEMO with limited content width ]] ([[https://gerrit.wikimedia.org/r/c/mediawiki/skins/Vector/+/607188|patch 607188]])
== Technical approach
- The setting is stored client-side in the browser's LocalStorage service.
- The setting is loaded right before the sidebar is rendered, thus avoiding an initial flicker if the sidebar would be shown and then immediately hidden.
- The sidebar is rendered and the setting loaded after the content is loaded, therefore the initial render of the above-the-fold content (first page) is not delayed by initializing the sidebar. That delay is barely measurable anyway.
- The state saving JavaScript is loaded asynchronously, typically after the sidebar is rendered. The sidebar can be toggled before that logic loads, but saving the state will be delayed until loading is done. This has no noticeable effect on the user experience unless the user very quickly (faster than the full load time) toggles the sidebar and reloads the page. This could be noticeable only on very slow connections and does not represent a beneficial use-case, therefore an accepted trade-off.
== Acceptance criteria
[] Make collapsible sidebar persistent during a single session for logged-out users (while they switch pages).
[] Make collapsible sidebar persistent between sessions for logged-out users not browsing in incognito mode (between browser restarts).
== Note on default states
INITIAL STATE: sidebar is default on for all users
EVENTUAL STATE: sidebar is default off for anons, default on for all other users
== Developer notes
Risk 1 - user preference may not save.
- The JavaScript responsible for saving the state is asynchronously loaded. The user might change the sidebar state before that's ready.
Risk 3- future anonymous support?
- Ready in the present.
== Questions
1. Do we need per device awareness?
- Provided by the way LocalStorage works.
1. What are the tradeoffs?
- Sidebar state not transferred between different browsers.
== Acceptance criteria
Sidebar retains state:
- [] while navigating between pages.
- [] when closing all wiki pages and reopening one.
- [] when restarting the browser.
Sidebar does NOT retain state:
- [] when closing or opening an incognito window.
- [] between browsers, devices.