Page MenuHomePhabricator

Make collapsible sidebar persistent for logged-in users
Closed, ResolvedPublic3 Estimated Story Points

Description

User Story

"As an editor, I frequently use the tools provided in the sidebar and would like it to remain open and available as I navigate the site".

As discussed in T246427, the collapsible sidebar should have the ability to maintain its collapsed/expanded state while navigating between pages. This task encompasses the work needed to implement that functionality for logged-in users only. The state will be tied to the users account, and will therefore persist across devices and loggged-in sessions as well.

Technical approach

  • We need to create a new hidden user-preference that stores the sidebar open/collapsed state.
  • Based on that preference, we conditionally set the checked attribute of the <input type="checkbox" class="vector-menu-checkbox vectorMenuCheckbox" aria-labelledby="{{label-id}}"> element in Menu.mustache in PHP.
  • When a user clicks the menu icon, we intercept that click with JS that sends an AJAX request to the API endpoint that updates the user-preference.

The user preference should not be visible as an option in Special:Preferences, since it would be redundant to have the same functionality in two places. That makes this a JS only feature.

Open questions

How do we handle narrow widths? If the design of the sidebar overlaps the content at very narrow widths and takes up lots of space, like it does on Minerva, then keeping it open across page-views would be unexpected an undesireable. [[design needed]]

Acceptance criteria

  • A feature flag exists that can be used to disable saves the database in the event the traffic is much higher than expected.

QA environment: Beta cluster

  • While logged in, the sidebar retains state:
    • while navigating between pages.
    • across devices.
    • after logging-out and logging back in again.

Sign off steps

  • Make sure we've reached out to the DBA with the deployment plan and expected traffic to the preferences database table

QA Results - Beta

Event Timeline

Should be noted that there is an extensive explanation why a modern, client-side approach is 1) simpler, 2) faster, 3) has no caching concerns, 4) serves also the majority of users (those unregistered):
T246427#6160536 + 2 essay sized comments up to T246427#6190020

Additionally that approach has a complete, working implementation: patch 592328 -- DEMO

This approach is unnecessarily complex, limited in scope (for only logged-in users) and reflects a decade-old server-side development methodology.
That being said, as this decision was already made without evaluating the pros and cons, I wish few bugs and merge conflicts while implementing this.

Change 606306 had a related patch set uploaded (by Aron Manning; owner: Aron Manning):
[mediawiki/core@master] checkboxHack: Trigger 'input' event when checkbox state changes

https://gerrit.wikimedia.org/r/606306

ovasileva set the point value for this task to 5.Jun 22 2020, 5:33 PM
ovasileva changed the point value for this task from 5 to 3.

Change 608756 had a related patch set uploaded (by Aron Manning; owner: Aron Manning):
[mediawiki/core@master] checkboxHack: Call onChange() callback when checkbox state changes

https://gerrit.wikimedia.org/r/c/mediawiki/core/ /608756

Change 608851 had a related patch set uploaded (by Jdrewniak; owner: Jdrewniak):
[mediawiki/skins/Vector@master] [WIP] Sidebar persistence for logged-in users in modern Vector.

https://gerrit.wikimedia.org/r/c/mediawiki/skins/Vector/ /608851

I think this should have been added to the task tree for accessibility. I made a best guess about the parent, feel free to correct if you had sg else in mind.

Change 608851 merged by jenkins-bot:
[mediawiki/skins/Vector@master] Sidebar persistence for logged-in users in modern Vector.

https://gerrit.wikimedia.org/r/608851

Change 610911 had a related patch set uploaded (by Jdrewniak; owner: Aron Manning):
[mediawiki/core@master] checkboxHack: Trigger 'input' event when checkbox state changes

https://gerrit.wikimedia.org/r/610911

Change 610920 had a related patch set uploaded (by Jdrewniak; owner: Jdrewniak):
[mediawiki/skins/Vector@master] Add enter/spacebar keyboard support to sidebar.

https://gerrit.wikimedia.org/r/610920

Change 610911 merged by jenkins-bot:
[mediawiki/core@master] checkboxHack: Trigger 'input' event when checkbox state changes

https://gerrit.wikimedia.org/r/610911

Change 610920 merged by jenkins-bot:
[mediawiki/skins/Vector@master] Add enter/spacebar keyboard support to sidebar.

https://gerrit.wikimedia.org/r/610920

Jdrewniak moved this task from Doing to QA on the Web-Team-Backlog (Kanbanana-FY-2020-21) board.
Jdrewniak updated the task description. (Show Details)

Test Result - Beta

Status: ✅ PASS
Environment: beta
OS: macOS Catalina
Browser: Chrome
Device: MBP, iPhone 11 Pro Max
Emulated Device: NA

Test Artifact(s):

QA steps

While logged in, the sidebar retains state:
✅ AC1: while navigating between pages.

ezgif.com-crop.gif (259×256 px, 1 MB)

✅ AC2: across devices.
While expanded on desktop I opened the page on my phone:

IMG_ED9CCD7DE52C-1.jpeg (2×1 px, 1 MB)

✅ AC3: I closed the sidebar on my phone:

IMG_6EB88A123ED6-1.jpeg (2×1 px, 1 MB)

✅ AC4: I reloaded the page on my desktop:

Screen Shot 2020-07-13 at 7.43.05 PM.png (1×1 px, 162 KB)

✅ AC5: after logging-out and logging back in again.

CollapsedExpanded
Screen Shot 2020-07-14 at 7.15.08 AM.png (1×1 px, 281 KB)
Screen Shot 2020-07-14 at 7.16.50 AM.png (1×1 px, 235 KB)
Edtadros updated the task description. (Show Details)

Change 612955 had a related patch set uploaded (by Jdrewniak; owner: Jdrewniak):
[mediawiki/skins/Vector@master] Add config to disable sidebar state persistence for logged-in users.

https://gerrit.wikimedia.org/r/612955

Change 612955 merged by jenkins-bot:
[mediawiki/skins/Vector@master] Add config to disable sidebar state persistence for logged-in users.

https://gerrit.wikimedia.org/r/612955

Change 620047 had a related patch set uploaded (by Phuedx; owner: Phuedx):
[mediawiki/skins/Vector@master] hooks: Don't send config variables unnecessarily

https://gerrit.wikimedia.org/r/620047

Change 620047 merged by jenkins-bot:
[mediawiki/skins/Vector@master] hooks: Don't send config variables unnecessarily

https://gerrit.wikimedia.org/r/620047