Page MenuHomePhabricator

Tables are forced to have display:block regardless of their size
Closed, ResolvedPublic

Assigned To
Authored By
lihaohong
Aug 16 2025, 12:46 AM
Referenced Files
F65962513: screenshot 16.mov.gif
Sep 5 2025, 1:04 AM
F65962511: screenshot 15.mov.gif
Sep 5 2025, 1:04 AM
F65962489: screenshot 14.mov.gif
Sep 5 2025, 12:54 AM
F65962476: screenshot 13.mov.gif
Sep 5 2025, 12:54 AM
F65912238: Screenshot 2025-08-25 at 3.18.45 PM.png
Aug 25 2025, 10:20 PM
F65810020: image.png
Aug 21 2025, 2:19 AM
F65757335: image.png
Aug 16 2025, 12:46 AM
F65757332: image.png
Aug 16 2025, 12:46 AM

Description

Example page:
https://en.wikipedia.org/w/index.php?title=User:PetraMagna/sandbox&oldid=1306107331

As can be seen in the screenshot, narrow tables are stretched, creating visual anomalies.

image.png (587×1 px, 51 KB)

The culprit is

@media all and (max-width: calc(640px - 1px)) {
    .mw-parser-output table {
        display: block;
        overflow: auto;
        max-width: 100%
    }
}

Adding width: fit-content fixes it and preserves the scrolling behavior.

image.png (1×3 px, 670 KB)

I don't know where this stylesheet lives and cannot submit a patch. I felt that someone may have already complained about this but only found passing mentions of it on T361838.

QA steps

Test on both mobile and desktop

Confirm the table doesn't have the colored area marked with a red cross:

Screenshot 2025-08-25 at 3.18.45 PM.png (100×478 px, 9 KB)

Requirement

Scope: Desktop and mobile web. Narrow tables must not be forced to stretch full width when screen width ≤640px.

  • Tables should render at their natural width (fit-content) while retaining horizontal scroll behavior when content exceeds viewport width.
  • Verify behavior on both desktop (resized window) and mobile (Minerva).

BDD

Feature: Tables respect natural width and allow scroll without stretching

  Scenario: Narrow table in small viewport
    Given I open a page containing a narrow table
    When I resize the viewport to ≤640px (desktop or mobile)
    Then the table width is fit to content (not stretched full width)
    And horizontal scrolling remains possible if needed

Test Steps

Test Case 1: Desktop narrow viewport table rendering

  1. Open page similar to https://en.wikipedia.beta.wmcloud.org/wiki/User:Jdlrobson/T402066?venotify=saved in a desktop browser.
  2. Resize the window to ≤640px.
  3. AC1: The table’s rendered width matches its content width (not stretched full width).
  4. AC2: Horizontal scroll is available when content exceeds viewport width.
  5. AC3: No extra colored background area appears beyond the table boundary.

Test Case 2: Mobile (Minerva) table rendering

  1. Open the same page on mobile (Minerva skin).
  2. Observe the table display in the default viewport.
  3. AC4: The table’s rendered width matches its content width (not stretched full width).
  4. AC5: Horizontal scroll is available when content exceeds viewport width.
  5. AC6: No extra colored background area appears beyond the table boundary.

QA Results - Beta

QA Results - Prod

Event Timeline

Looks like the CSS was added as a result of T330527. I'm surprised it passed all the quality control steps considering how it breaks smaller tables on narrower screens.

(For reference, that css lives here; and was added in change 1035034.)

Jdlrobson-WMF subscribed.

Yes this is by design and intentional compromise. If it doesn't do this then the skin ceases to be responsive and will not adapt to mobile.

For the more broader unsolved problem here please see T361737: [EPIC] With the current layout, some elements extend beyond the content area and overlap sticky page tools

The proposed fix does not compromise responsiveness in any way. It simply removes the problematic borders on the right.

In particular, width: fit-content gets overridden by max-width: 100% with the screen is narrow, so I don't understand why this needs to be closed. It should be a strict improvement over the current solution.

@lihaohong the code serves both mobile and desktop and I don't believe fit-content has any effect there.

Change #1180679 had a related patch set uploaded (by Peter Li; author: Peter Li):

[mediawiki/core@master] Skin: Table width should not exceed content width

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

@lihaohong the code serves both mobile and desktop and I don't believe fit-content has any effect there.

I'm not sure what you mean by not having any effect. It works on dev tools and modifying the less file works on my local installation of MediaWiki: the extraneous border on the right is gone after width: fit-content.

Change #1180695 had a related patch set uploaded (by Peter Li; author: Peter Li):

[mediawiki/skins/MinervaNeue@master] Table width should not exceed content width

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

@Jdlrobson-WMF I uploaded a patch for MinervaNeue as well. Minerva's CSS is a bit different, but I think the outcome is the same. The extra gray background mentioned in T361838 should be gone without compromising the scrolling behavior for larger tables.

image.png (1×3 px, 804 KB)

Change #1180695 merged by jenkins-bot:

[mediawiki/skins/MinervaNeue@master] Table width should not exceed content width

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

Change #1180679 merged by jenkins-bot:

[mediawiki/core@master] Skin: Table width should not exceed content width

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

Change #1184733 had a related patch set uploaded (by Jdlrobson; author: Esanders):

[mediawiki/skins/MinervaNeue@master] Fix task link in comment

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

Test Result - Beta

Status: ✅ PASS
Environment: beta
OS: macOS Sequoia 15.5
Browser: Chrome Canary (latest as of test date)
Device: MS
Emulated Device: NA

Test Case 1: Desktop narrow viewport table rendering

  1. Open https://en.wikipedia.beta.wmcloud.org/wiki/User:Jdlrobson/T402066?venotify=saved in a desktop browser.
  2. Resize the window to ≤640px.
  3. ✅ ⬜ ❌ ❓ AC1: The table’s rendered width matches its content width (not stretched full width).
  4. ✅ ⬜ ❌ ❓ AC2: Horizontal scroll is available when content exceeds viewport width.
  5. ✅ ⬜ ❌ ❓ AC3: No extra colored background area appears beyond the table boundary.

screenshot 13.mov.gif (717×1 px, 2 MB)

Test Case 2: Mobile (Minerva) table rendering

  1. Open the same page on mobile (Minerva skin).
  2. Observe the table display in the default viewport.
  3. ✅ ⬜ ❌ ❓ AC4: The table’s rendered width matches its content width (not stretched full width).
  4. ✅ ⬜ ❌ ❓ AC5: Horizontal scroll is available when content exceeds viewport width.
  5. ✅ ⬜ ❌ ❓ AC6: No extra colored background area appears beyond the table boundary.

screenshot 14.mov.gif (956×1 px, 3 MB)

Test Result - Prod

Status: ✅ PASS
Environment: testiwiki
OS: macOS Sequoia 15.5
Browser: Chrome Canary (latest as of test date)
Device: MS
Emulated Device: NA

Test Case 1: Desktop narrow viewport table rendering

  1. Open https://en.wikipedia.beta.wmcloud.org/wiki/User:Jdlrobson/T402066?venotify=saved in a desktop browser.
  2. Resize the window to ≤640px.
  3. ✅ ⬜ ❌ ❓ AC1: The table’s rendered width matches its content width (not stretched full width).
  4. ✅ ⬜ ❌ ❓ AC2: Horizontal scroll is available when content exceeds viewport width.
  5. ✅ ⬜ ❌ ❓ AC3: No extra colored background area appears beyond the table boundary.

screenshot 15.mov.gif (956×1 px, 2 MB)

Test Case 2: Mobile (Minerva) table rendering

  1. Open the same page on mobile (Minerva skin).
  2. Observe the table display in the default viewport.
  3. ✅ ⬜ ❌ ❓ AC4: The table’s rendered width matches its content width (not stretched full width).
  4. ✅ ⬜ ❌ ❓ AC5: Horizontal scroll is available when content exceeds viewport width.
  5. ✅ ⬜ ❌ ❓ AC6: No extra colored background area appears beyond the table boundary.

screenshot 16.mov.gif (956×1 px, 2 MB)

Change #1186680 had a related patch set uploaded (by Peter Li; author: Peter Li):

[mediawiki/skins/MinervaNeue@REL1_44] Table width should not exceed content width

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

Change #1186680 merged by jenkins-bot:

[mediawiki/skins/MinervaNeue@REL1_44] Table width should not exceed content width

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

Change #1187047 had a related patch set uploaded (by SomeRandomDeveloper; author: Peter Li):

[mediawiki/core@REL1_44] Skin: Table width should not exceed content width

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

Change #1187047 merged by jenkins-bot:

[mediawiki/core@REL1_44] Skin: Table width should not exceed content width

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