Skip to content

fix: show correct paragraph font in toolbar when selection is empty (SD-2145)#2402

Merged
harbournick merged 2 commits intomainfrom
luccas/sd-2145-bug-on-select-all-toolbar-reflects-default-font-name-even
Mar 17, 2026
Merged

fix: show correct paragraph font in toolbar when selection is empty (SD-2145)#2402
harbournick merged 2 commits intomainfrom
luccas/sd-2145-bug-on-select-all-toolbar-reflects-default-font-name-even

Conversation

@luccas-harbour
Copy link
Contributor

Problem
When the cursor lands inside an empty paragraph, the toolbar never reflects the paragraph’s paragraphProperties font family because it only reads active marks or linked-style overrides; newly inserted runs still inherit the paragraph font, so the toolbar value was wrong.

Solution

  • Activate the paragraph runProperties font family (via encodeMarksFromRPr) whenever the selection is collapsed inside an empty paragraph and no font-family mark/link override is active.
  • Track selection/paragraph state so the fallback only runs when appropriate and doesn’t override existing active states.
  • Added regression tests covering the new fallback and the “paragraph already has text” guard, plus mocking the resolved paragraph helpers.

@linear
Copy link

linear bot commented Mar 16, 2026

@luccas-harbour luccas-harbour force-pushed the luccas/sd-2145-bug-on-select-all-toolbar-reflects-default-font-name-even branch from abb8286 to 7fac727 Compare March 16, 2026 14:54
@luccas-harbour luccas-harbour self-assigned this Mar 16, 2026
@luccas-harbour luccas-harbour marked this pull request as ready for review March 16, 2026 15:10
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7fac7275c6

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@luccas-harbour luccas-harbour force-pushed the luccas/sd-2145-bug-on-select-all-toolbar-reflects-default-font-name-even branch from fd49b70 to c405a19 Compare March 16, 2026 16:22
Copy link
Collaborator

@harbournick harbournick left a comment

Choose a reason for hiding this comment

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

LGTM

@harbournick harbournick merged commit 39e1477 into main Mar 17, 2026
13 checks passed
@harbournick harbournick deleted the luccas/sd-2145-bug-on-select-all-toolbar-reflects-default-font-name-even branch March 17, 2026 22:08
@superdoc-bot
Copy link
Contributor

superdoc-bot bot commented Mar 17, 2026

🎉 This PR is included in superdoc-cli v0.3.0-next.5

The release is available on GitHub release

@superdoc-bot
Copy link
Contributor

superdoc-bot bot commented Mar 17, 2026

🎉 This PR is included in superdoc v1.19.1-next.4

The release is available on GitHub release

harbournick pushed a commit that referenced this pull request Mar 18, 2026
# [1.20.0](v1.19.1...v1.20.0) (2026-03-18)

### Bug Fixes

* behavior tests ([#2436](#2436)) ([2d087f2](2d087f2))
* change default link protocol ([#2319](#2319)) ([1deda06](1deda06))
* **cli:** restore tracked diff redline roundtrip ([#2438](#2438)) ([f609371](f609371))
* **comments:** resolve double-click activation and edit mode issues (SD-2035) ([#2259](#2259)) ([d9465aa](d9465aa))
* **diffing:** ignore volatile OOXML attrs in image and paragraph diff comparison ([#2421](#2421)) ([ca91225](ca91225))
* **doc-api:** gate textStyle attrs and sync reference coverage ([#2430](#2430)) ([e2d6ca6](e2d6ca6))
* **docs:** coherence pass on doc api, clean up dead code, update CLI SKILL.md ([#2424](#2424)) ([bf0d4b8](bf0d4b8))
* **document-api:** add document diff API and fix tracked diff replay in CLI host session ([#2418](#2418)) ([2a804f7](2a804f7))
* **editor:** prevent scroll-to-top when clicking toolbar buttons ([#2236](#2236)) ([ab30a36](ab30a36))
* guard drawing export against invalid structures and zero IDs (SD-824) ([#2363](#2363)) ([9c7fc2e](9c7fc2e))
* improve multi-column rendering ([#2369](#2369)) ([d231640](d231640))
* **lists:** stabilize list item addresses for docs without paraIds ([#2429](#2429)) ([0070de6](0070de6))
* newline formatting inheritance without serializing style-derived formatting (SD-2228) ([#2417](#2417)) ([5a3318f](5a3318f))
* open links in view mode ([#2350](#2350)) ([25f0aad](25f0aad))
* **presentation-editor:** arrow key scroll-into-view with unconstrained containers (SD-1950) ([#2411](#2411)) ([fa8afc8](fa8afc8)), closes [#findScrollableAncestor](https://github.com/superdoc-dev/superdoc/issues/findScrollableAncestor)
* register DOCX numbering metadata for lists.create ([#2432](#2432)) ([129772f](129772f))
* seed base docx package for collaboration exports ([#2416](#2416)) ([df36853](df36853))
* show correct paragraph font in toolbar when selection is empty (SD-2145) ([#2402](#2402)) ([39e1477](39e1477))
* **super-editor:** guard against style definition nodes without elements ([#2379](#2379)) ([7dd57f8](7dd57f8))
* text selection inside headers/footers ([#2404](#2404)) ([09677dc](09677dc))
* **toc:** inject _Toc bookmarks so exported DOCX TOC links work without manual Update Table ([#2431](#2431)) ([54c5aa7](54c5aa7))

### Features

* **comments:** add scrollToComment API ([#2440](#2440)) ([0132d0e](0132d0e))
* **doc-info:** add live page counts to doc.info ([#2435](#2435)) ([e631f4b](e631f4b))
* **doc-info:** live doc.info counts for characters, tracked changes, SDT fields, and lists ([#2428](#2428)) ([2978507](2978507))

### Reverts

* Revert "fix(types): fix broken .d.ts imports in published superdoc package (S…" ([#2443](#2443)) ([33215ee](33215ee))
@harbournick
Copy link
Collaborator

🎉 This PR is included in superdoc v1.20.0

The release is available on GitHub release

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants