(Go: >> BACK << -|- >> HOME <<)

Page MenuHomePhabricator

[SPIKE, 8hrs] Review possible ways that gadgets might be affected by page tools feature
Closed, ResolvedPublic1 Estimated Story Points

Description

The page tools feature will move elements in the existing sidebar/main menu into what is currently the more menu.

The more menu will evolve to become the page tools feature which will be displayable as a dropdown or pinnable to the right hand side of the page.

This could potentially impact gadgets.

Things to think about

  • Most gadgets should be using mw.util.addPortletLink at this time to add menu items. Presumably these should continue to work, but are there any situations where we are changing the associated menu ID
  • Some gadgets create entire menus e.g. Twinkle where there is no standardized API. How could these be implicated by pinnable functionality?
  • Certain gadgets append elements with JavaScript click handlers. How would these be impacted?

Questions to answer

  • How might gadgets be broken?
  • How might new gadgets use the new functionality (think outside the box on this one! the more crazy the better)
  • How does pinning functionality interact with gadgets / how could it interact?
  • Does the hook approach serve all our potential needs for modifying Vector-specific menu items. Could this be re-thought (T291700)
  • How should gadgets add entire new menus going forward in a sustainable way (T303859) ?

Event Timeline

Jdlrobson set the point value for this task to 1.Nov 15 2022, 6:33 PM
ovasileva raised the priority of this task from Medium to High.Nov 21 2022, 3:32 PM

This Spike is quite open-ended, so I’ll break this analysis down into 2 parts.

  1. Current Page Tools compatibility with gadgets
  2. How can we enable gadgets to use the new Pinnable functionality.

Page Tools gadget compatibility

Twinkle

✅ Works with Page Tools menu (pinned and unpinned)
The TW menu inserts itself after the Page Tools menu.

Screen Shot 2022-12-09 at 1.19.52 PM.png (461×562 px, 142 KB)
MoreMenu

✅ Works with Page Tools menu (pinned and unpinned)
The "Page" menu is inserted before the Page Tools menu.
The "User" menu, only visible on user pages, is also inserted before the Page Tools menu.

Screen Shot 2022-12-09 at 1.19.45 PM.png (474×558 px, 85 KB)
Screen Shot 2022-12-12 at 11.40.35 AM.png (1×956 px, 208 KB)
ProseSize

✅ Works with Page Tools menu (pinned and unpinned)

Screen Shot 2022-12-09 at 1.20.41 PM.png (574×1 px, 290 KB)
RTRC

✅ Works with Page Tools menu (pinned and unpinned)

Screen Shot 2022-12-12 at 10.10.48 AM.png (1×1 px, 589 KB)

“Allow navigation menus to be collapsed”
  • ❌ Does not work for any menus in Vector 2022, but possibly superseded by future designs
“Add a toolbox link to reload the current page with the system message names exposed”

✅ Works with Page Tools menu (pinned and unpinned)

  • adds the "messages" item in the Page Tools menu

Screen Shot 2022-12-09 at 1.22.09 PM.png (599×1 px, 347 KB)

“Add a toolbox link to reload the current page with Resource Loader in debug mode”

✅ Works with Page Tools menu (pinned and unpinned)

  • adds the "debug" item in the Page Tools menu

Screen Shot 2022-12-09 at 1.22.09 PM.png (599×1 px, 347 KB)

Summary

After examining various gadgets, I haven't found any adverse affects related to the new Page Tools menu. I tested gadgets in production as well as locally and didn't see any breakage (except for the collapsible menus gadget).

We were able to maintain compatibility for a few reasons:

  1. The Page Tools menu is rendered server-side, which maintains the expected JS execution order (i.e. the expected HTML menu exists when the gadget JS executes).
  2. We maintain the same IDs that were previously used to target this menu by gadgets.
  3. When we move the menu, we maintain the JS behaviour and events that have already been bound to the HTML elements by gadgets.

Although not available on production yet, I also tested the Page Tools persistence feature with gadgets and did not notice any loss of functionality. The only noticeable difference is that, when the menu is pinned by default, you can sometimes see the addition of new links after the page loads. This could potentially cause a layout-shift, but that would only be an issue if the Page Tools was pinned by default for anonymous users and a gadget that adds a link was also enabled for anonymous users (unlikely).

Jdlrobson renamed this task from [SPIKE] Review possible ways that gadgets might be affected by page tools feature to [SPIKE, 8hrs] Review possible ways that gadgets might be affected by page tools feature.Dec 12 2022, 6:38 PM
Jdlrobson moved this task from Upcoming to Doing on the Web-Team-Backlog (Kanbanana-2022-23-Q2) board.

I left a comment on T325097 for that specific script. I think reverting the last edit should resolve that issue (it was caused by a workaround for T315639).

Regarding the second part of this spike, exposing the Pinnable functionality to gadget, I have a short write-up below.

Enabling gadgets to use the PinnableHeader

In order to expose the pinnable functionality to gadgets, the following technical refactors would have to happen:

  1. Package the PinnableHeader component as a resourceLoader module. This module would have to include the related styles, javascript and templates for the PinnableHeader.
  2. Provide an imperative way to instantiate the PinnableHeader. Currently, the pinnableHeader is initialized declaratively by looking through the DOM for a .vector-pinnable-header class (on pageload). Gadgets kick-in after pageload, so they would need to instantiate the pinnableHeader themselves via JS. A constructor-based approach like new PinnableHeader() might be more appropriate for this use case.

However, exposing just the pinnable header, without the related menu templates, doesn’t make much sense since they work in unison. That topic is covered in T303859.

Another open question about exposing pinnability is how useful is it without a persistence layer (I’d argue not very much). We currently tie pinnability to a user preference, but gadgets don't have that ability. They could however, use localStorage instead (which is reasonable). In order to support that though, we would have to refactor the pinnable header code to accommodate multiple persistence strategies instead of just the one we have now.

Another question is how useful is this functionality to gadgets in general? Currently, pinnability really only works when moving a menu from the tabs into the end-column. What about moving a menu into the start-column? (ToC sidebar) or into the header? or from the header into the tabs? Although our API is generic enough to handle this, we haven't tested what these variations would look like outside our specific Page Tools use-case.

Summary

I'd recommend further exploration before undertaking this work. More generic UI customization is desirable, but pinnability feels like a very specialized feature that would work in a well-defined framework. I'm not sure it's something we can build upon to move towards that kind of framework though.