Skip to content

fix(text-editor): scale paragraph content font with the size prop - #8147

Merged
tamas-sage merged 3 commits into
masterfrom
fix/FE-7740-text-editor-content-font-size
Oct 22, 2026
Merged

tamas-sage merged 3 commits into
masterfrom
fix/FE-7740-text-editor-content-font-size

Conversation

@tamas-sage

Copy link
Copy Markdown
Contributor

Proposed behaviour

the editor should apply size-based paragraph typography consistently across all paragraph content, including links and mention pill text. The mapping should be small = global/font/static/comp/regular/S, medium = global/font/static/comp/regular/M, and large = global/font/static/comp/regular/L, while preserving bold and italic styling.

Current behaviour

the TextEditor size updates the surrounding editor styling, but paragraph content inside the editor does not consistently inherit the size-specific font token. The paragraph node still applies a fixed typography setup of 400 / 21px / 14px, so links and text inside mention pills can stay on the wrong font, which is most noticeable at large size.

Checklist

  • Commits follow our style guide
  • Related issues linked in commit messages if required
  • Screenshots are included in the PR if useful
  • All themes are supported if required
  • Unit tests added or updated if required
  • Playwright automation tests added or updated if required
  • Storybook added or updated if required
  • Translations added or updated (including creating or amending translation keys table in storybook) if required
  • Typescript d.ts file added or updated if required
  • Related docs have been updated if required

QA

  • Tested in provided StackBlitz sandbox/Storybook
  • Add new Playwright test coverage if required
  • Carbon implementation matches Design System/designs
  • UI Tests GitHub check reviewed if required

Additional context

Testing instructions

@tamas-sage
tamas-sage requested review from a team as code owners August 25, 2026 09:00
@tamas-sage
tamas-sage marked this pull request as draft August 25, 2026 09:00
@tamas-sage tamas-sage self-assigned this Aug 25, 2026
@tamas-sage
tamas-sage requested a lite review from Copilot August 27, 2026 11:53

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates Carbon’s TextEditor typography so paragraph content (including links and mention pill text) scales with the size prop by relying on inherited paragraph font tokens, while retaining bold/italic formatting behavior.

Changes:

  • Apply size-based paragraph font tokens on the editor container via StyledTextEditor.
  • Update StyledSpanNode to avoid writing inline fontSize/lineHeight for paragraph preset spans so they inherit from the editor.
  • Update mention pill styling to inherit font, and add unit tests covering the new paragraph inline-style behavior.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/components/text-editor/text-editor.style.ts Adds size→paragraph font token mapping and applies it on the editor container.
src/components/text-editor/text-editor.component.tsx Passes the computed size into StyledTextEditor so typography can be applied consistently.
src/components/text-editor/internal/nodes/styled-span.node.ts Skips inline font size/line height for paragraph preset spans to allow size-based inheritance.
src/components/text-editor/internal/nodes/styled-span.node.test.tsx Adds tests validating paragraph spans don’t set inline font size/line height, including transitions to/from other presets.
src/components/text-editor/internal/nodes/mention.node.ts Makes mention pill text inherit font so it scales with editor size.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/components/text-editor/__internal__/__nodes__/styled-span.node.ts Outdated
Comment thread src/components/text-editor/__internal__/__nodes__/mention.node.ts
const node = StyledSpanNode.createFromOption("paragraph", "Body text");
const domElement = node.createDOM(staticConfig);

// eslint-disable-next-line jest-dom/prefer-to-have-style

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: I'm guessing we're having to ignore the linter here due to some weirdness of Lexical?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, exactly. It is not a Lexical bug, we are intentionally checking direct inline style values on element.style (including empty string cases), and toHaveStyle is less precise for that specific assertion.

@tomdavies73
tomdavies73 self-requested a review September 11, 2026 10:45
@tomdavies73
tomdavies73 removed their request for review September 15, 2026 15:23
@tamas-sage
tamas-sage requested review from DipperTheDan and ibutakova and a lite review from Copilot September 21, 2026 13:02

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

A moderate blocking import issue and unresolved editable/browser coverage gaps remain.

Review effort: Lite
Findings: None

Resolved since last review (2)

DipperTheDan
DipperTheDan previously approved these changes Sep 22, 2026
ibutakova
ibutakova previously approved these changes Sep 22, 2026
@dariusbercea-sage
dariusbercea-sage marked this pull request as ready for review September 25, 2026 08:26
@tamas-sage
tamas-sage dismissed stale reviews from ibutakova and DipperTheDan via d274c55 October 20, 2026 08:05
@tamas-sage
tamas-sage force-pushed the fix/FE-7740-text-editor-content-font-size branch from f98fa97 to e39ef22 Compare October 21, 2026 12:52
@tamas-sage
tamas-sage merged commit 44182f3 into master Oct 22, 2026
30 checks passed
@tamas-sage
tamas-sage deleted the fix/FE-7740-text-editor-content-font-size branch October 22, 2026 07:48
@carbonci

Copy link
Copy Markdown
Collaborator

🎉 This PR is included in version 162.14.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Labels

Development

Successfully merging this pull request may close these issues.

7 participants