Page MenuHomePhabricator

Message: Fix height of CSS-only message icon
Closed, ResolvedPublic

Description

Background

In T396519: Message: Improve readability and usability a use of line-height was introduced 8aafb2a333 to vertically align the icon with the surrounding text. This Icon height override in Message component is now vertically misaligning the Message icon in certain contexts.

This fix now breaks icon height, because Vue icon styles override message styles:

.cdx-message .cdx-message__icon, .cdx-message .cdx-message__icon--vue {
  height: var(--line-height-medium,1.625rem);
}
.cdx-message--warning .cdx-message__icon {
  min-width: 10px;
  min-height: 10px;
  width: calc(var(--font-size-medium,1rem) + 4px);
  height: calc(var(--font-size-medium,1rem) + 4px);
  display: inline-block;
  vertical-align: text-bottom;
}

For example, see warning message in the hidden diff.

image.png (69×128 px, 1 KB)

This was reported first by @SerDIDG in T398529#11048062

Developer notes

  • We can already see one issue in the output code above. The min-width and min-height of the icon, even at small font-size would be too small with 10px for a medium-sized icon at 18px . This would not fix the issue though.
  • Setting a line-height token to height is bad practice and here has actually undiscovered caused a regression. While the Codex docs site falls back to a valid CSS var rem value, the height is set to equivalent of 1.5714285 unit-less hence resulting in the rendering issue.
  • The whole concept of min-width and min-height is highly probable not necessary anymore. It was invented at times of Internet Explorer in order to prevent SVG rendering blurriness on lo-dpi screens.

Requirement

Scope: Desktop and mobile web. The Message component icon must display at the correct height without vertical misalignment:

  • The .cdx-message__icon styles must not override or distort the icon height.
  • Warning messages (and other variants) must show icons sized consistently with surrounding text.
  • Vue icon styles must not conflict with base message styles.

BDD

Feature: Correct height for Message component icons

  Scenario: Warning message icon alignment
    Given a warning message is rendered
    When the message icon is displayed
    Then the icon height matches the expected size (font-size + 4px)
    And the icon is vertically aligned with the text

Test Steps

Test Case 1: Warning message icon alignment

  1. Open a page rendering a warning message (e.g., Codex demo or component sandbox).
  2. Inspect the message icon in DevTools.
  3. AC1: The icon height equals calc(var(--font-size-medium,1rem) + 4px).
  4. AC2: The icon is vertically aligned with the text (CSS vertical-align: text-bottom).
  5. AC3: No extra line-height override misaligns the icon.

QA Results - Prod

ACStatusDetails
1T401457#11194828
2T401457#11194828
3T401457#11194828

Event Timeline

Setting a line-height token to height is bad practice and here has actually undiscovered caused a regression. While the Codex docs site falls back to a valid CSS var rem value, the height is set to equivalent of 1.5714285 unit-less hence resulting in the rendering issue.

line-height-medium is supposed to be 1.625rem in Codex. But Vector overrides it and sets it to 1.5714285 without a unit, which breaks the Codex code that was expecting rems.

Change #1184567 had a related patch set uploaded (by Catrope; author: Catrope):

[mediawiki/skins/Vector@master] Fix display of Codex message icons

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

Change #1184567 merged by jenkins-bot:

[mediawiki/skins/Vector@master] Fix display of Codex message icons

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

Change #1184583 had a related patch set uploaded (by Catrope; author: Catrope):

[mediawiki/skins/Vector@wmf/1.45.0-wmf.17] Fix display of Codex message icons

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

Change #1184584 had a related patch set uploaded (by Catrope; author: Catrope):

[mediawiki/skins/Vector@wmf/1.45.0-wmf.16] Fix display of Codex message icons

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

Change #1184584 merged by jenkins-bot:

[mediawiki/skins/Vector@wmf/1.45.0-wmf.16] Fix display of Codex message icons

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

Change #1184583 merged by jenkins-bot:

[mediawiki/skins/Vector@wmf/1.45.0-wmf.17] Fix display of Codex message icons

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

Mentioned in SAL (#wikimedia-operations) [2025-09-03T20:59:23Z] <catrope@deploy1003> Started scap sync-world: Backport for [[gerrit:1184584|Fix display of Codex message icons (T401457)]], [[gerrit:1184583|Fix display of Codex message icons (T401457)]]

Mentioned in SAL (#wikimedia-operations) [2025-09-03T21:06:01Z] <catrope@deploy1003> catrope: Backport for [[gerrit:1184584|Fix display of Codex message icons (T401457)]], [[gerrit:1184583|Fix display of Codex message icons (T401457)]] synced to the testservers (see https://wikitech.wikimedia.org/wiki/Mwdebug). Changes can now be verified there.

Mentioned in SAL (#wikimedia-operations) [2025-09-03T21:12:44Z] <catrope@deploy1003> Finished scap sync-world: Backport for [[gerrit:1184584|Fix display of Codex message icons (T401457)]], [[gerrit:1184583|Fix display of Codex message icons (T401457)]] (duration: 13m 20s)

matmarex assigned this task to Catrope.

Actually, this is not completely fixed. D:

The icon in the warning here is correct: https://www.mediawiki.org/w/index.php?title=Project:Village_Pump&diff=7709633&uselang=en

image.png (52×1 px, 6 KB)

But the icon in the warning here is still cut off: https://www.mediawiki.org/w/index.php?title=Project:Village_Pump&oldid=7853400&uselang=en

image.png (70×1 px, 11 KB)

(I noticed this when reviewing the various test cases linked in T398529)

Change #1184630 had a related patch set uploaded (by VolkerE; author: VolkerE):

[mediawiki/skins/Vector@master] Fix display of Codex message icons II

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

Seems like it's b/c the problematic Message is outside .mw-body-content, just inside .mw-body. Above patch amends the Vector temp fix approach once more to accommodate for this. Not sure if Messages would ever live outside .mw-body, but estimate the chance at maximum esoterically low numbers.

Not sure if Messages would ever live outside .mw-body

I’m pretty sure it can: for example, #mw-teleport-target is outside .mw-body, and popups are actually pretty likely to contain messages. The FlaggedRevs review interface is also outside .mw-body, and although AFAIK it doesn’t use messages right now, it, or similar extensions, could. Couldn’t you just change the selector to simply .cdx-message, or .cdx-message.cdx-message if more specificity is needed?

Not sure if Messages would ever live outside .mw-body

I’m pretty sure it can: for example, #mw-teleport-target is outside .mw-body, and popups are actually pretty likely to contain messages. The FlaggedRevs review interface is also outside .mw-body, and although AFAIK it doesn’t use messages right now, it, or similar extensions, could. Couldn’t you just change the selector to simply .cdx-message, or .cdx-message.cdx-message if more specificity is needed?

Indeed. I went looking for examples, and I found the banner we currently show on Special:AccountSecurity, which would not be fixed by the proposed patch:

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

Change #1184630 merged by jenkins-bot:

[mediawiki/skins/Vector@master] Fix display of Codex message icons II

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

Change #1185159 had a related patch set uploaded (by Catrope; author: VolkerE):

[mediawiki/skins/Vector@wmf/1.45.0-wmf.17] Fix display of Codex message icons II

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

Change #1185159 merged by jenkins-bot:

[mediawiki/skins/Vector@wmf/1.45.0-wmf.17] Fix display of Codex message icons II

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

Mentioned in SAL (#wikimedia-operations) [2025-09-08T21:04:20Z] <catrope@deploy1003> Started scap sync-world: Backport for [[gerrit:1185159|Fix display of Codex message icons II (T401457)]]

Mentioned in SAL (#wikimedia-operations) [2025-09-08T21:10:00Z] <catrope@deploy1003> catrope: Backport for [[gerrit:1185159|Fix display of Codex message icons II (T401457)]] synced to the testservers (see https://wikitech.wikimedia.org/wiki/Mwdebug). Changes can now be verified there.

Mentioned in SAL (#wikimedia-operations) [2025-09-08T21:21:06Z] <catrope@deploy1003> Finished scap sync-world: Backport for [[gerrit:1185159|Fix display of Codex message icons II (T401457)]] (duration: 16m 46s)

Edtadros subscribed.

Test Result - Prod

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

Test Case 1: Warning message icon alignment

  1. Open a page rendering a warning message (e.g., Codex demo or component sandbox).
  2. Inspect the message icon in DevTools.
  3. AC1: The icon height equals calc(var(--font-size-medium,1rem) + 4px).
  4. AC2: The icon is vertically aligned with the text (CSS vertical-align: text-bottom).
  5. AC3: No extra line-height override misaligns the icon.

screenshot 167.png (1×1 px, 623 KB)