Page MenuHomePhabricator

VE toolbar does not resize when new Vector sidebar opened or closed
Closed, ResolvedPublic

Description

Behavior

  1. Visit: https://patchdemo.wmflabs.org/wikis/557db5804f/wiki/Douglas_Adams
  2. Log in or create an account
  3. Return to https://patchdemo.wmflabs.org/wikis/557db5804f/wiki/Douglas_Adams
  4. Make sure the site-wide sidebar is expanded (you'll know if it is if you see links to Main page , Recent changes, Random page, etc.)
  5. Scroll down the page a bit until the site-wide sticky header appears
  6. Click the "✏️" affordance within the sticky header to open VE
  7. Click the << in the top left corner of the page to collapse the site-wide sidebar
  8. Scroll down the page a bit

Actual

  1. ❗️ VE's toolbar does not span the width of the content:

Screen Shot 2022-02-02 at 9.55.31 PM.png (792×1 px, 338 KB)

Expected

  1. ✅ VE's toolbar responds to the site-wide sidebar being collapsed and expands to span the width of the content

Event Timeline

Change 759555 had a related patch set uploaded (by DLynch; author: DLynch):

[mediawiki/skins/Vector@master] Trigger a window resize event when toggling sidebar state

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

Esanders renamed this task from VE toolbar does not respond to how sidebar behaves to VE toolbar does not resize when new Vector sidebar opened or closed.Feb 4 2022, 12:35 PM

@DLynch The patch demo link in the description is dead

So it is. I'm not sure exactly which one Peter linked to, but I imagine that any patchdemo with the stick header edit button enabled would work. e.g. this one: https://patchdemo.wmflabs.org/wikis/dd823293fa/wiki/The_Hitchhiker%27s_Guide_to_the_Galaxy

Change 759555 merged by jenkins-bot:

[mediawiki/skins/Vector@master] Trigger a window resize event when toggling sidebar state

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

This looks good now. See

Screenshot 2022-02-15 at 18.38.48.png (570×3 px, 185 KB)
. It spans the width of the content as expected.

The code to trigger the window resize event is inside the saveSidebarState() function, which has a 1000 ms debounce when it is called from bindSidebarClickEvent(). Thus, there is an undesirable delay of 1 second before repositioning the elements when the sidebar is toggled. This trigger of a "fake" window resize event should be decoupled from the API save, and executed immediately. This will result in a much snappier interface. And of course, triggering the fake window resize event and saving the state to API are two completely different things, which shouldn't be blended together.

In the current case, there is no need to throttle/debounce the handler, executing such event once (and in response to an user click) is very cheap, the issue might be it gets executed repeatedly, for example in a real window resize.

For the record, I noticed this issue when editing AbuseFilters, as there was a delay before the Ace editor got resized.


Another thing: in collapseSidebar() and expandSidebar() functions, note they call saveSidebarState()() in a way that every time they are called, they create and call a new debounced saveSidebarState function… The debouncing isn't coded correctly (there should be an single instance of the debounced function). As a result, it's basically as if the function wasn't debounced. Thus, the API save happens without debouncing, but fortunately, the event is triggered only when the media query passes through the max-width: 999px threshold.

Also notice the timeout of the debounce is 0 ms. I think it's intended so that the handler gets lower priority than the most important things such as recalculation of display. Still, the debouncing should be fixed as I exposed in the above paragraph. (edit: or maybe it's because the only way to make an API save (and nothing else) is to call saveSidebarState() with timeout=0 and shouldTriggerResize=false, as the code is nested into this function)

Change 885267 had a related patch set uploaded (by Gerrit Patch Uploader; author: Anne Haunime):

[mediawiki/skins/Vector@master] Separate the fake resize event from the API save

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