Skip to content

Fix white underline/strikethrough lines when text or background color is applied#4032

Draft
Copilot wants to merge 4 commits into
mainfrom
copilot/fix-underline-strikethrough-color
Draft

Fix white underline/strikethrough lines when text or background color is applied#4032
Copilot wants to merge 4 commits into
mainfrom
copilot/fix-underline-strikethrough-color

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 3, 2026

Underline and strikethrough decoration lines render white after applying text or background color, because document.execCommand('foreColor') wraps content inside <u>/<strike> — but CSS text-decoration-color resolves to currentColor of the decorating element, not its children. So <u> inherits the theme's fg color (white in dark mode) regardless of the inner <font> tag.

Root cause

<!-- execCommand produces this structure -->
<u><font color="#000000">text</font></u>
<!-- <u> still inherits white from theme → white underline -->

<!-- correct structure needed -->
<font color="#000000"><u>text</u></font>
<!-- <u> now inherits black from <font> → black underline ✓ -->

Changes

  • src/actions/formatSelection.ts — After foreColor execCommand in the whole-thought case, normalizes the contentEditable HTML to move color tags (<font>, <span> with color/background-color) outside of decoration tags (<u>, <strike>). Fires a synthetic input event so the debounced thought-value update picks up the corrected HTML.

    Two private helpers added:

    • isColorElement(el) — identifies <font> or <span> with color/background-color
    • normalizeColoredDecoration(html) — walks decoration elements bottom-up, hoisting sole color-element children above the decoration wrapper
  • src/e2e/puppeteer/__tests__/color.ts — Three new tests asserting the correct HTML structure after: underline + text color, underline + background color, strikethrough + text color.

Only normalizes when the decoration element has exactly one child that is a color element (covers the whole-thought color application path). Partial-selection cases with multiple color spans are out of scope.

Copilot AI and others added 3 commits April 3, 2026 19:59
Copilot AI changed the title [WIP] Fix underline and strikethrough color when applying text or background color Fix white underline/strikethrough lines when text or background color is applied Apr 3, 2026
Copilot AI requested a review from raineorshine April 3, 2026 20:10
@raineorshine
Copy link
Copy Markdown
Contributor

@raineorshine raineorshine added the hold Pause development label Apr 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hold Pause development

Projects

None yet

Development

Successfully merging this pull request may close these issues.

White line for Underline and Strikethrough when user applies Text or Background Color

2 participants