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

Restricted Application added subscribers: Liuxinyu970226, Aklapper. · View Herald TranscriptJun 17 2020, 11:13 PM
Demian added a subscriber: Demian.Jun 18 2020, 12:07 AM

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.

ovasileva triaged this task as High priority.Jun 18 2020, 9:47 AM

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.
Jdlrobson updated the task description. (Show Details)Jun 22 2020, 5:36 PM
Jdrewniak updated the task description. (Show Details)Jun 22 2020, 5:43 PM
Restricted Application added a subscriber: Masumrezarock100. · View Herald TranscriptJun 22 2020, 5:43 PM

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

Volker_E updated the task description. (Show Details)Jul 1 2020, 6:28 AM

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.

Demian moved this task from Incoming to Awaiting Review on the User-Demian board.

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 reassigned this task from Jdrewniak to Edtadros.Jul 13 2020, 12:03 PM
Jdrewniak updated the task description. (Show Details)
Jdrewniak updated the task description. (Show Details)Jul 13 2020, 12:05 PM

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.

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

✅ AC3: I closed the sidebar on my phone:

✅ AC4: I reloaded the page on my desktop:

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

CollapsedExpanded
Edtadros updated the task description. (Show Details)Jul 14 2020, 2:21 PM
Edtadros updated the task description. (Show Details)
Jdrewniak added a subscriber: Edtadros.

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

Jdrewniak removed Jdrewniak as the assignee of this task.Jul 16 2020, 9:15 AM

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