Page MenuHomePhabricator

TOC menu and clicking behavior
Closed, ResolvedPublic3 Estimated Story Points

Description

Description

The table of contents is presented as a sidebar by default. It can also be presented as a menu (this happens automatically below 1000px, and there will eventually be a control that allows people to do this manually). This task is about two clicking behavior things.

When the TOC menu is open (at any screen size):

  1. clicking anywhere outside the TOC menu should close it
  2. clicking on a link within the TOC menu should close it (note: this also automatically scrolls you to that section).
    • Example of another menu on our site that works like this (from Recent changes):

Documentation of current behavior

AC

  • Clicking outside of the collapsed TOC button will close it
  • Clicking on a link inside the collapsed TOC menu will close it
  • collapsed TOC menu can be toggled with enter or space button

Event Timeline

Since the collapsed TOC uses the checkbox hack, this can be accomplished by using JS to progressively enhancing the collapsed TOC. Most of the other checkbox hacks in Vector contain links, so this issue hasn't come up before.

We could potentially make this change in core inside checkboxHack.js, but we'd have to consider how to generalize this to work with other checkbox hack implementations. This feature only makes sense in the context of a dropdown menu (as do some of the other existing enhancements in core like bindDismissOnClickOutside and bindDismissOnFocusLoss). If we do include this in core, we should improve our documentation on when a particular enhancement should be used, or even consider renaming the bind function to be bindDropdown.

Another thing to consider, in this case we only want to close the TOC when links inside a dropdown are clicked, and not the subsection toggle buttons. However I could imagine a dropdown in the future that uses buttons instead of links.

bwang removed bwang as the assignee of this task.Jun 23 2022, 9:50 PM
ovasileva triaged this task as Medium priority.Jun 27 2022, 10:34 AM
alexhollender_WMF renamed this task from Clicking on a link in the TOC menu should close TOC to TOC menu and clicking behavior.Jun 29 2022, 5:54 PM
alexhollender_WMF updated the task description. (Show Details)
alexhollender_WMF updated the task description. (Show Details)
ovasileva raised the priority of this task from Medium to High.Jul 1 2022, 2:21 PM
Jdlrobson lowered the priority of this task from High to Medium.Jul 19 2022, 5:09 PM

there's a related situation when you click the Beta link when already on the Preferences page:

this seems like an edge case. not sure if it's worth addressing as part of this task...

there's a related situation when you click the Beta link when already on the Preferences page:

We just declined this one: T312779

ovasileva raised the priority of this task from Medium to High.Jul 25 2022, 5:29 PM

Change 817353 had a related patch set uploaded (by Bernard Wang; author: Bernard Wang):

[mediawiki/skins/Vector@master] Ensure collapsible TOC is closed when links are clicked

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

Change 817348 had a related patch set uploaded (by Jdlrobson; author: Bernard Wang):

[mediawiki/core@master] mediawiki.page.ready: Add bindDismissOnClickLink to checkboxHack.js

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

Change 817348 merged by jenkins-bot:

[mediawiki/core@master] mediawiki.page.ready: Add bindDismissOnClickLink to checkboxHack.js

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

Change 817353 merged by jenkins-bot:

[mediawiki/skins/Vector@master] Ensure collapsible TOC is closed when links are clicked

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

bwang assigned this task to Edtadros.
bwang updated the task description. (Show Details)
bwang added a subscriber: Mabualruz.

Change 822420 had a related patch set uploaded (by Jdlrobson; author: Jdlrobson):

[mediawiki/core@master] mediawiki.page.ready: Correct function documentation for checkbox

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

Change 822420 merged by jenkins-bot:

[mediawiki/core@master] mediawiki.page.ready: Correct function documentation for checkbox

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

vaughnwalters subscribed.

AC Passes:

  • Clicking outside of the collapsed TOC button will close it
  • Clicking on a link inside the collapsed TOC menu will close it

Screen Recording 2022-08-17 at 3.46.12 PM.mov-14D1ED8F-3E4C-44D0-8F87-35715CF75A4E.gif (456×720 px, 3 MB)


I am tabbing to the element and then testing it with spacebar / enter here:

  • collapsed TOC menu can be toggled with enter or space button

spacebar enter.mov-A32B3834-7CDF-49FE-9122-12FB62173FC2.gif (518×720 px, 456 KB)

Test wiki created on Patch demo by AHollender (WMF) using patch(es) linked to this task:
https://patchdemo.wmflabs.org/wikis/54ea6fb561/w

Testing on enwiki.
Clicking outside of the collapsed TOC button will close it - passes
Clicking on a link inside the collapsed TOC menu will close it - passes
collapsed TOC menu can be toggled with enter or space button - passes

Looks good! Resolving.

Test wiki on Patch demo by AHollender (WMF) using patch(es) linked to this task was deleted:

https://patchdemo.wmflabs.org/wikis/54ea6fb561/w/