Page MenuHomePhabricator

At low resolutions, on certain pages, when items collapse into a more menu, the label can flow onto another line
Closed, ResolvedPublic3 Estimated Story PointsBUG REPORT

Description

For pages where no more menu exists on the page, at lower resolutions the items collapse into a dropdown menu. For certain languages the label is wrapping onto a new line.

If the more menu already exists this bug does not occur.

resize.gif (427×551 px, 1 MB)

QA

Issue:
The dropdown menu label wraps to a new line.

Screen Shot 2021-11-30 at 12.03.02 PM.png (182×646 px, 21 KB)

in beta

In production

Developer notes

p-cactions-label sets a width via a style attribute inside resources/skins.vector.legacy.js/collapsibleTabs.js for animation purposes.

This width should likely be removed at the end of the animation.

Original Description

The normal form of p-cactions header would not be wrapped to a new line like below.

hh2.jpg (117×651 px, 20 KB)

But when p-cactions came from collapsed p-views element (for example, in the sandbox page), the header would be wrapped around to a new line like below.

hh1.jpg (112×671 px, 17 KB)

Edited description #1

This is from one of the comments I wrote
I checked the elements console and it seems like h3 width style is one pixel too short.

I have created 4 comparison tables between multiple configurations, with safemode enabled, without any gadgets or user scripts, and without any special permissions other than users and autoconfirmed. All of them present the same bug, being that the width of p-cactions from collapsed p-views is smaller than normal p-cactions by 1px.

The texts in red are the width of p-cactions for each of the pictures. The 4 tables are as follow:

  1. Legacy Vector in Chrome comparing NS:0 (#p-cactions present since the beginning) and NS:6 (#p-cactions present only after shrinking the width),

wikichrome.png (2×2 px, 1 MB)

  1. Legacy Vector in Firefox comparing NS:0 (#p-cactions present since the beginning) and NS:6 (#p-cactions present only after shrinking the width),

wikifirefox.png (2×2 px, 1 MB)

  1. New Vector in Chrome comparing NS:0 (#p-cactions present since the beginning) and NS:6 (#p-cactions present only after shrinking the width),

newvectorchrome.png (2×2 px, 287 KB)

  1. New Vector in Firefox comparing NS:0 (#p-cactions present since the beginning) and NS:6 (#p-cactions present only after shrinking the width),

newvectorfirefox.png (2×2 px, 342 KB)

AC

  • Ensure the more menu button expands and collapses as normal
  • Ensure the width of the '#p-cactions' nav element equals the calculated width of '.p-cactions-label'. In the case of English wikipedia, it should be 8+29.6333+24-1 = 60.6333px

QA Results - Beta

ACStatusDetails
1T294883#7632701
2T294883#7632701

QA Results - Prod

ACStatusDetails
1T294883#7633519
2T294883#7633519

Event Timeline

I just checked WP:SANDBOX on enwiki, and p-cactions header there is also one pixel shorter than the usual form of it.

Jdlrobson subscribed.

Thanks for the report! I am unable to replicate or understand this bug, so I need some more information.

  1. What screen resolution are you seeing this bug on?
  1. Does this issue occur on https://th.wikipedia.org/wiki/หน้าหลัก?useskinversion=1&uselang=th&safemode=1 ?
  1. If the issue does not occur with above URL, what gadgets are enabled on https://th.wikipedia.org/wiki/%E0%B8%9E%E0%B8%B4%E0%B9%80%E0%B8%A8%E0%B8%A9:%E0%B8%81%E0%B8%B2%E0%B8%A3%E0%B8%95%E0%B8%B1%E0%B9%89%E0%B8%87%E0%B8%84%E0%B9%88%E0%B8%B2#mw-prefsection-gadgets (screenshot or list would be helpful) ?

Desktop improvements = the new version of Vector. This bug relates to the old version so removing Desktop Improvements (Vector 2022) tag.

Jdlrobson renamed this task from New p-cactions from collapsed p-views makes a broken button header in thwiki to [Legacy Vector] p-cactions from collapsed p-views makes a broken button header in thwiki.Nov 3 2021, 3:22 PM

Thanks for the report! I am unable to replicate or understand this bug, so I need some more information.

  1. What screen resolution are you seeing this bug on?
  1. Does this issue occur on https://th.wikipedia.org/wiki/หน้าหลัก?useskinversion=1&uselang=th&safemode=1 ?
  1. If the issue does not occur with above URL, what gadgets are enabled on https://th.wikipedia.org/wiki/%E0%B8%9E%E0%B8%B4%E0%B9%80%E0%B8%A8%E0%B8%A9:%E0%B8%81%E0%B8%B2%E0%B8%A3%E0%B8%95%E0%B8%B1%E0%B9%89%E0%B8%87%E0%B8%84%E0%B9%88%E0%B8%B2#mw-prefsection-gadgets (screenshot or list would be helpful) ?

Desktop improvements = the new version of Vector. This bug relates to the old version so removing Desktop Improvements (Vector 2022) tag.

  1. My screen resolution is 1920x1080 with 125% scaling, but this bug happens if the screen width is very small that tabs need to be collapsed, as shown below.

this.jpg (1×1 px, 258 KB)

  1. It does, as above.

And the same happens with enwiki (using the same way) too! But less noticeable because the "More" text fits inside the smaller space.

Adding back Desktop Improvements (Vector 2022) tag because this bug also occurs there too.

this.jpg (1×1 px, 344 KB)

I removed all the gadget, only adding importScript('User:Bebiezaza/iScript/main.js'); to my common.js page. This is testable only in pages that don't have the p-cactions tab and not a home page, because I prevent this userscript from showing tabs inside the home page, so testing in WP:SANDBOX is the easiest in all cases.

Bebiezaza renamed this task from [Legacy Vector] p-cactions from collapsed p-views makes a broken button header in thwiki to p-cactions from collapsed p-views is smaller than usual.Nov 4 2021, 7:18 AM

This is enwiki in new vector, with Twinkle enabled, and I altered the twinkle menu label to be longer.

The width of "More" menu is smaller than usual here

image.png (1×1 px, 300 KB)

because when I disabled the style="width: 60.625px;", the button expands out a little bit.

image.png (1×1 px, 299 KB)

(May need pixel counting to see it being different here)

The same above applies to enwiki in legacy vector too with Twinkle enabled too.

image.png (1×1 px, 373 KB)

image.png (1×1 px, 373 KB)

(May need pixel counting to see it being different here)

The list of gadgets I enabled in enwiki:

  • 1 to 11) All default gadgets
  • 12) Twinkle
  • 13) HotCat
Aklapper renamed this task from p-cactions from collapsed p-views is smaller than usual to Width of p-cactions from collapsed p-views is smaller than usual.Nov 4 2021, 9:41 AM

We only support the case where gadgets and user scripts/styles are disabled. If there's bugs with Twinkle etc, those will need to be addressed inside those gadgets/scripts.

I'm starting to wonder if this is a browser bug. Perhaps this is language + Operating system or browser specific. What operating system / browser are you using?

I cannot replicate this without gadgets on Chrome or Firefox on Mac.
This is what I'm seeing:

Screen Shot 2021-11-05 at 10.15.09 AM.png (658×1 px, 299 KB)

Screen Shot 2021-11-05 at 10.21.23 AM.png (668×1 px, 367 KB)

Are you able to replicate this on English Wikipedia without gadgets enabled?

You need to do it in https://th.wikipedia.org/wiki/WP:SANDBOX with no administrator rights as there should be no “เพิ่มเติม” tab present before shrinking the page’s width.

This is replicable in both enwiki and thwiki without any gadgets and scripts enabled, but it’s less noticeable in enwiki. I’m using Chrome in Windows 10.

This bug is also replicable in Safari in 9.7” iPad with iPadOS 14.8 and English localization and no gadgets enabled.

70F98386-39B3-49E3-AF1D-5A91003C8E3D.png (1×2 px, 1 MB)

(Please excuse me about the right side, that's from my school's work)

Bebiezaza changed the subtype of this task from "Task" to "Bug Report".Nov 10 2021, 6:14 PM

I have created 4 comparison tables between multiple configurations, with safemode enabled, without any gadgets or user scripts, and without any special permissions other than users and autoconfirmed. All of them present the same bug, being that the width of p-cactions from collapsed p-views is smaller than normal p-cactions by 1px.

The texts in red are the width of p-cactions for each of the pictures. The 4 tables are as follow:

  1. Legacy Vector in Chrome comparing NS:0 (#p-cactions present since the beginning) and NS:6 (#p-cactions present only after shrinking the width),

wikichrome.png (2×2 px, 1 MB)

  1. Legacy Vector in Firefox comparing NS:0 (#p-cactions present since the beginning) and NS:6 (#p-cactions present only after shrinking the width),

wikifirefox.png (2×2 px, 1 MB)

  1. New Vector in Chrome comparing NS:0 (#p-cactions present since the beginning) and NS:6 (#p-cactions present only after shrinking the width),

newvectorchrome.png (2×2 px, 287 KB)

  1. New Vector in Firefox comparing NS:0 (#p-cactions present since the beginning) and NS:6 (#p-cactions present only after shrinking the width),

newvectorfirefox.png (2×2 px, 342 KB)

From looking into the code and messing around with inspect element, I have found out that the reason p-cactions is smaller than usual by 1px is that the code gets the width of p-cactions nav, which is already correct, but it puts the width scaling into h3 element, which has margin-right:-1px in it, which makes the width calculation off by 1px. From my calculation, this is correct because

padding-leftwidthpadding-rightmargin-righttotal
+8px+40.412px+24px-1px= 71.412px

and 71.412px is equal to the comparison table photo above in Legacy Vector in Chrome in Thai Wikipedia in NS:6.

I have devised two fixes for this problem although I have done it in MW version 1.35.2, so some additional changes are expected. The first method is more destructive than the latter:

1. Editing the MenuDropdown.less file (more destructive)

The reason this is more destructive is that this expands all the dropdown menu sizes, which could break other kinds of stuff.

In MenuDropdown.less at line 118-129 (#mw-head .vector-menu-dropdown h3), change the margin property in line 123 to all 0.

Diff

MenuDropdown.less
	#mw-head .vector-menu-dropdown h3 {
	// Tab separator: Outer end (right in LTR) border of "Actions" menu.
	background-position: right bottom;
	float: left;
	height: unit( 40 / @font-size-tabs / @font-size-browser, em );
-	margin: 0 -@border-width-base 0 0;
+	margin: 0;
	// `padding-right` >= `1px` effectively moves the "background border" outside of the element to
	// act like a real border. It is necessary for `.vector-menu-dropdown .vector-menu-content-list` dropdown to align well.
	// 0.5em equals `8px` at computed `font-size` of `14px` as visually harmonically with
	// `padding-left` in `.vector-menu-dropdown h3 a`
	padding-right: unit( 24 / @font-size-tabs / @font-size-browser, em );
}

2. Editing the vector.js file (less destructive)

The reason this is less destructive is that this only affects the invisible #p-cactions dropdown menu size.

In vector.js at line 26-52 ( $tabContainer.on('beforeTabCollapse') and $tabContainer.on('beforeTabExpand') )

  1. change line 38 from $cactions.find( 'h3' ) to $cactions
  2. change line 47 from $cactions.find( 'h3' ).animate( { width: '1px' }, 'normal', function () { to $cactions.animate( { width: '1px' }, 'normal', function () {
  3. and (this part does not exist in the current code anymore) change line 50 from .parent().addClass( 'emptyPortlet vector-menu-empty' ); to .addClass( 'emptyPortlet vector-menu-empty' );
    1. From reading the current code, I assume that this does not need any changes

Diff

After

vector.js
		$tabContainer
		.on( 'beforeTabCollapse', function () {
			var expandedWidth;
			// If the dropdown was hidden, show it
			if ( !mw.util.isPortletVisible( cactionsId ) ) {
				mw.util.showPortlet( cactionsId );
				// Now that it is visible, force-render it virtually
				// to get its expanded width, then shrink it 1px before we
				// yield from JS (which means the expansion won't be visible).
				// Then animate from the 1px to the expanded width.
				expandedWidth = $cactions.width();
				// eslint-disable-next-line no-jquery/no-animate
-				$cactions.find( 'h3' )
+				$cactions
					.css( 'width', '1px' )
					.animate( { width: expandedWidth }, 'normal' );
			}
		} )
		.on( 'beforeTabExpand', function () {
			// If we're removing the last child node right now, hide the dropdown
			if ( $cactions.find( 'li' ).length === 1 ) {
				// eslint-disable-next-line no-jquery/no-animate
-				$cactions.find( 'h3' ).animate( { width: '1px' }, 'normal', function () {
+				$cactions.animate( { width: '1px' }, 'normal', function () {
					$( this ).attr( 'style', '' );
					mw.util.hidePortlet( cactionsId );
				} );
			}
		} )

I am sorry if this is not the best way to type this kind of information out.

EDIT1: actually found a way to make code block display fewer lines.
EDIT2: finally using diff language.

Jdlrobson lowered the priority of this task from Medium to Low.Nov 30 2021, 7:59 PM
Jdlrobson renamed this task from Width of p-cactions from collapsed p-views is smaller than usual to At low resolutions, on certain pages, when items collapse into a more menu, the label can flow onto another line.Nov 30 2021, 8:08 PM
Jdlrobson updated the task description. (Show Details)

I've only looked at this briefly, but would setting white-space: nowrap; CSS be sufficient for preventing the label from breaking onto two lines?
e.g.

.vector-menu-dropdown-noicon h3 {
    white-space: nowrap;
}

@Jdrewniak just tried that CSS out and yep that seems to fix this!

Yes, it fixed the text displaying, but the nav size is still one pixel narrower than normal.

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

[mediawiki/skins/Vector@master] Fix caction menu button from having a width that's 1px too small

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

bwang removed bwang as the assignee of this task.Jan 5 2022, 9:14 PM
bwang moved this task from Doing to Code Review on the Web-Team-Backlog (Kanbanana-FY-2021-22) board.
bwang subscribed.

Change 751803 merged by jenkins-bot:

[mediawiki/skins/Vector@master] Fix caction menu button from having a width that's 1px too small

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

Test Result - Beta

Status: ✅ PASS
Environment: beta
OS: macOS Monterey
Browser: Chrome
Device: MBP
Emulated Device:NA

Test Artifact(s):

QA Steps

In an incognito window, visit https://en.wikipedia.beta.wmflabs.org/wiki/?useskinversion=1&uselang=th
Resize browser to around 586px.
✅ AC1: Ensure the more menu button expands and collapses as normal

Screen Recording 2022-01-19 at 6.55.54 AM.mov.gif (290×576 px, 109 KB)

✅ AC2: Ensure the width of the '#p-cactions' nav element equals the calculated width of '.p-cactions-label'.
p-cactions width 72.5156
calculated .p-cactions-label = 8+41.5156+24-1 = 72.5156
Screen Shot 2022-01-19 at 6.57.44 AM.png (790×1 px, 370 KB)

Screen Shot 2022-01-19 at 6.56.42 AM.png (450×1 px, 218 KB)

Edtadros subscribed.

Test Result - Prod

Status: ✅ PASS
Environment: thwiki
OS: macOS Monterey
Browser: Chrome
Device: MBP
Emulated Device:NA

Test Artifact(s):

QA Steps

In an incognito window, visit https://th.wikipedia.org/wiki/%E0%B8%A7%E0%B8%B4%E0%B8%81%E0%B8%B4%E0%B8%9E%E0%B8%B5%E0%B9%80%E0%B8%94%E0%B8%B5%E0%B8%A2:%E0%B8%97%E0%B8%94%E0%B8%A5%E0%B8%AD%E0%B8%87%E0%B9%80%E0%B8%82%E0%B8%B5%E0%B8%A2%E0%B8%99?useskinversion=1&uselang=th
Resize browser to around 586px.
✅ AC1: Ensure the more menu button expands and collapses as normal

Screen Recording 2022-01-19 at 9.32.08 AM.mov.gif (290×576 px, 86 KB)

✅ AC2: Ensure the width of the '#p-cactions' nav element equals the calculated width of '.p-cactions-label'.
p-cactions width 72.5156
calculated .p-cactions-label = 8+41.5156+24-1 = 72.5156

Screen Shot 2022-01-19 at 9.32.44 AM.png (493×1 px, 228 KB)

Screen Shot 2022-01-19 at 9.33.08 AM.png (811×1 px, 364 KB)