Skip to content

Notes: stop the highlight tint from deepening, emphasize markers with an underline - #80544

Closed
adamsilverstein wants to merge 2 commits into
trunkfrom
fix/note-highlight-text-contrast
Closed

adamsilverstein wants to merge 2 commits into
trunkfrom
fix/note-highlight-text-contrast

Conversation

@adamsilverstein

@adamsilverstein adamsilverstein commented Jul 21, 2026 •

Copy link
Copy Markdown
Member

What?

Holds an inline note marker's tint at one low alpha in every state, and moves the hover / focus / selected emphasis to an opaque underline in the author's color.

Fixes #80543, raised by @joedolson in #80498 (comment).

Why?

The tint is painted behind the marker's text, so it is subtracted from whatever text/background contrast the theme already provides, and there is no contrast assessment anywhere in that path. Worse, the alpha doubled from 0x40 (25%) to 0x80 (50%) on hover, focus, and selection, so the strong state cost roughly twice as much as the resting one.

WCAG 2.1 contrast of the theme's own text color against the tinted background, worst palette member per state:

Theme Baseline 25% 50%
Default editor (#fff / #1e1e1e) 16.67 11.35 7.29
Dark (#1e1e1e / #fff) 16.67 9.20 4.74
Mid-tone (#767676 / #fff) 4.54 3.49 2.67
Warm (#f5e6c8 / #4a3b1f) 8.80 6.14 4.10

The default editor is comfortable throughout. The damage lands on themes whose own pair is already near the 4.5:1 floor, where selecting a note could drop passing text to 2.67:1.

Why not color: contrast-color(...)

That was the original suggestion, and it backfires here. contrast-color() only sees the color it is handed; it cannot know the backdrop, and through a 25% tint the backdrop is most of what the reader sees. Deriving the text color from the raw author color picks wrong in exactly the common case:

Author color picks result on the default white canvas
Purple #6F42C1 white 1.5:1, down from 11.35:1
Teal #0F766E white 1.4:1, down from 11.66:1
Orange #FBBF24 black fine on white, 2.3:1 on a dark canvas

contrast-color() is sound over an opaque background, which a translucent highlight is not. (Browser support is not the obstacle: it went Baseline Newly Available in April 2026 and degrades to inherited color.)

So instead of trying to compute a text color we cannot compute, this bounds what the highlight is allowed to cost: one fixed, small tint, and emphasis that does not sit behind the glyphs.

How?

In note-highlight-styles.js:

  • REST_ALPHA / ACTIVE_ALPHA collapse to a single TINT_ALPHA (0x40, unchanged from today's resting value).
  • :hover, :focus-within, and the selected-note rule now emit text-decoration-line: underline with text-decoration-color set to the opaque author color, 0.125em thick at a 0.15em offset. text-decoration follows text across line wraps natively, which box-shadow or border-bottom on an inline element would not.

An opaque line is a stronger signal than a heavier wash, so the emphasis state reads more clearly while costing the text nothing.

Scope: inline markers only, on trunk. #80498 applies the same helper to whole text blocks and inherits TINT_ALPHA on merge; the right block-level equivalent of the underline is an open question there and in #80543, since a paragraph-wide underline is not appropriate.

Testing Instructions

Try in WordPress Playground

  1. Enable notes, select a phrase in a paragraph, and add a note.
  2. Click elsewhere to deselect. The phrase carries the soft tint, as before.
  3. Hover the marker, and select the note in the sidebar. The marker gains an underline in the author's color, and the tint behind the text does not deepen.
  4. Confirm the marker is still easy to spot and to trace back to its thread.

Automated

  • npm run test:unit packages/editor/src/components/collab-sidebar/test/note-highlight-styles.js - 10 passing, including a new case asserting no rule can emit a background alpha above the rest value.
  • npm run test:e2e -- test/e2e/specs/editor/various/block-notes.spec.js - 45 passing on a reset environment. The selected-marker case was rewritten to assert the underline and to assert the tint stays put; run against trunk's implementation first it fails, as expected.

Screenshots

Selected inline marker, before (50% wash)
note-highlight-before

after (25% wash plus underline):
note-highlight-after

Open question for review

@jasmussen @joedolson - the underline is deliberately conservative. If the emphasis reads too quietly for connecting a canvas marker to its sidebar thread, the thickness and offset are the dials, and #80543 also asks whether the at-rest marking should move off the background entirely.

…derline

The per-author tint sits behind the marker's text, so it is subtracted from
whatever text/background contrast the theme provides, and the canvas background
comes from theme.json, so the composited result cannot be measured from CSS.
Doubling the alpha on hover, focus, and selection doubled that loss: on a
mid-tone canvas an orange-authored marker dropped from a passing 4.54:1 to
2.67:1.

Hold the tint at the rest alpha in every state and carry emphasis with an
opaque underline in the author's color instead, which reads more strongly than
a heavier wash without touching what sits behind the text.
@adamsilverstein adamsilverstein added Collaborative Workflows Phase 3 of the Gutenberg roadmap around all-things related to collaborative workflows [Type] Bug An existing feature does not function as intended Needs Accessibility Feedback Need input from accessibility Needs Design Feedback Needs general design feedback. labels Jul 21, 2026
@github-actions github-actions Bot added the [Package] Editor /packages/editor label Jul 21, 2026
@github-actions

Copy link
Copy Markdown

Size Change: +58 B (0%)

Total Size: 7.74 MB

📦 View Changed
Filename Size Change
build/scripts/editor/index.min.js 500 kB +58 B (+0.01%)

compressed-size-action

@adamsilverstein

Copy link
Copy Markdown
Member Author

cc: @fcoveram for review as well

@github-actions

github-actions Bot commented Jul 21, 2026 •

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: adamsilverstein <adamsilverstein@git.wordpress.org>
Co-authored-by: noruzzamans <noruzzaman@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>
Co-authored-by: jasmussen <joen@git.wordpress.org>
Co-authored-by: joedolson <joedolson@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions

Copy link
Copy Markdown

Flaky tests detected in 648981b.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/29870507365
📝 Reported issues:

@noruzzamans

Copy link
Copy Markdown
Contributor

Tested on WordPress Playground, confirms the fix works as expected. The tint stays the same in both rest and selected states, and selecting/hovering the marker adds an underline in the author's color instead of deepening the background.

One side note: when selecting a note, the rest of the text gets a dimming overlay. Not sure if this is expected in this environment or pre-existing behavior unrelated to this PR, flagging in case it's useful.

Screen.Recording.2026-07-22.at.7.42.15.AM.mov

@Mamaduka

Copy link
Copy Markdown
Member

Thanks, @adamsilverstein!

Let's get some design feedback before committing to this.

@jasmussen

Copy link
Copy Markdown
Contributor

If the contrast is insufficient in the present state, then as suggested, an underline is a good next step. I think we can refine the thickness, we want to not confuse with hyperlinks, I wonder if 1.5px is right.

One thing though: can we make the underline the same color as the user avatar and marking itself? Only full-opacity. I guess that due to the possible light and dark modes, using currentColor is the most safe. But can we then at least try to seed in some of the highlight color through color-mix? Worth testing more in-depth, but something like color-mix(in srgb, [highlightcolor] 30%, currentColor). With a little eyedropping it seems like we can get the most colorful border possible across the color ranges, yet still be safely within the 3:1 contrast ratio that seems necessary here. WDYT?

@adamsilverstein

Copy link
Copy Markdown
Member Author

One thing though: can we make the underline the same color as the user avatar and marking itself?

Sure I can try that. I'm going to bring this into the combined PR suggested by @Mamaduka so we can see all these related changes working together.

@adamsilverstein

Copy link
Copy Markdown
Member Author

Closing in favor of the combined PR:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Collaborative Workflows Phase 3 of the Gutenberg roadmap around all-things related to collaborative workflows Needs Accessibility Feedback Need input from accessibility Needs Design Feedback Needs general design feedback. [Package] Editor /packages/editor [Type] Bug An existing feature does not function as intended

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Notes: highlight tints reduce text contrast, and the strong state doubles the loss

4 participants