Page MenuHomePhabricator

Edit Check: Improve the contrast of the highlighted text
Closed, ResolvedPublic

Description

Background

The current color used to highlighted text is not contrasted enough on the page's background either when, either when unselected and selected. At the moment, the highlighted text is using opacity, which makes the color even less contrasted on the background.

Captura de pantalla 2026-02-25 a las 10.12.04.png (1×2 px, 872 KB)
Checks and Suggestions combined in a page
Screenshot 2026-02-04 at 22.03.04.png (1×744 px, 554 KB)
This issue is particularly pronounced with the duplicate links suggestion

We need to find possible solutions to make the highlighted text more contrasted on the page's background without losing the accessibility contrast for links.

Considerations

  • Links within the text are contrasted enough just when placing on the color-50 value (e.g. yellow-50), so we cannot use a darker color in order to keep the 4.5:1 contrast with links.
  • Currently, opacity is used to prevent highlights from obscuring text, which was a previous technical limitation. However, with mix-blend-mode: multiply created in T269145 we could use a non-opacity color.
  • We need to consider non-test cases (images, references, etc.) where the highlighted works different than in text.
  • The highlight is rendered as rectangular DOM overlays rather than true text lines, so in complex layouts (e.g., with subscripts, floated images, or references) the shapes break apart.
    CleanShot 2026-02-24 at 11.50.08@2x.png (296×2 px, 141 KB)
  • The Custom Highlight API would allow applying styles directly to highlighted text (e.g. underline). However, browser support is still partial, and it does not cover non-text elements (e.g. images, references).

Possible solutions

image.png (1×1 px, 280 KB)
image.png (1×1 px, 282 KB)
image.png (1×1 px, 295 KB)
Approach 1Approach 2AApproach 2B
  • Approach 1: Update color of highlighted lines to make them more contrasted.
    • Unselected highlighted: background-color-interactive using opacity-medium 0.65 to avoid this gray to be as prominent as when selected
    • Selected Check: background-color-warning-subtle
    • Selected Suggestion: background-color-progressive-subtle
  • Approach 2: Update de color + Include underline to differentiate between unselected and selected states
    • 2A: Include a dashed underline for when the highlighted is selected
    • 2B: Include underline when the highlighted is unselected, so it's clearly differentiate from selected state while it's visible when non selected

Acceptance criteria (or Done)

Design

  • Explore solutions to increase the contrast of highlighted text

Implementation

  • Implement the decided solution

Future task

Event Timeline

This issue is particularly pronounced with the duplicate links suggestion:

Screenshot 2026-02-04 at 22.03.04.png (1×744 px, 554 KB)

It's important that we work on these improvements since now the highlighted text is too subtle, especially when just some words are highlighted from the paragraph.

Captura de pantalla 2026-02-10 a las 11.59.49.png (1×714 px, 195 KB)

Captura de pantalla 2026-02-10 a las 12.00.17.png (1×714 px, 175 KB)

Captura de pantalla 2026-02-10 a las 12.00.33.png (1×716 px, 182 KB)

At the moment, opacity is used in code to prevent highlights from obscuring text, which was a previous technical limitation. However, with mix-blend-mode: multiply created in T269145 we could use a non-opacity color.

Based on this, I propose the following:

image.png (1×1 px, 280 KB)
image.png (1×1 px, 282 KB)
image.png (1×1 px, 295 KB)
Approach 1Approach 2AApproach 2B
  • Approach 1: Update color of highlighted lines to make them more contrasted.
    • Unselected highlighted: background-color-interactive using opacity-medium 0.65 to avoid this gray to be as prominent as when selected
    • Selected Check: background-color-warning-subtle
    • Selected Suggestion: background-color-progressive-subtle
  • Approach 2: Update de color + Include underline to differentiate between unselected and selected states
    • 2A: Include a dashed underline for when the highlighted is selected
    • 2B: Include underline when the highlighted is unselected, so it's clearly differentiate from selected state while it's visible when non selected

In case including underline in the highlighted lines is complex, we could start by implementing Approach 1, see how it works and test it. In case we still detect issues to solve, we could implement any of the Approach 2 solutions.

At the moment, opacity is used in code to prevent highlights from obscuring text, which was a previous technical limitation. However, with mix-blend-mode: multiply created in T269145 we could use a non-opacity color.

I think DavidL was not quite right on this - we've been using opacity AND mix-blend-mode, mostly because our original colour choices were not based on codex tokens, but we can switch to using codex tokens with 100% opacity. The visual change will be quite subtle, but will improve dark mode rendering.

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

[mediawiki/extensions/VisualEditor@master] EditCheck: Use solid design-token colours for highlights

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

Test wiki created on Patch demo by BMartinezCalvo (WMF) using patch(es) linked to this task:
https://e124ab14ea.catalyst.wmcloud.org/w/

The Approach 1 is not be enough to indicate multiple suggestions in the same highlighted text since the color of the highlighted text unselected and selected are too similar for suggestions:

Captura de pantalla 2026-03-17 a las 14.08.13.png (1×2 px, 242 KB)

The multiselection is not visible enough when multiple suggestions (and checks) and unselected.

Captura de pantalla 2026-03-17 a las 14.09.15.png (974×2 px, 179 KB)

For this reason, I think we should find a way to implement Approach 2 in order to differentiate more the unselected and selected states.

image.png (1×5 px, 1 MB)

Change #1243897 merged by jenkins-bot:

[mediawiki/extensions/VisualEditor@master] EditCheck: Use solid design-token colours for highlights

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

DLynch subscribed.

Confirmed with Barbara that all the remaining work here will be done in other tickets. 👍