Skip to content

fix(muya): stop the quick-insert hint claiming a line of its own - #5283

Merged
Jocs merged 3 commits into
developfrom
fix/5282-soft-break-extra-line
Sep 10, 2026
Merged

Jocs merged 3 commits into
developfrom
fix/5282-soft-break-extra-line

Conversation

@Jocs

@Jocs Jocs commented Sep 10, 2026

Copy link
Copy Markdown
Member

Fixes #5282

A paragraph ending in a soft line break rendered one blank line too many until something was typed on the new line: press Shift+Enter and everything below jumps down a line, type one character and it jumps back.

Root cause

Not the mu-line-end span, which was my first guess and wrong. The same markup measured in the same page:

container height
class="mu-content" 51px (2 lines)
class="mu-content mu-paragraph-content" 77px (3 lines)

mu-paragraph-content appears in exactly one place in the stylesheet — the quick-insert hint:

.mu-show-quick-insert-hint .mu-paragraph.mu-active > .mu-paragraph-content:first-of-type::after {
    content: attr(placeholder);
}

placeholder is only set while the quick-insert menu is open (ui/paragraphQuickInsertMenu/index.ts:80, removed again at :82). The rest of the time the declaration resolves to an empty string — but the ::after box is still generated, and an empty box still takes part in layout (measured: ::after content="").

A block ending in a soft line break ends with the block-level mu-line-end span, and an inline box cannot share a line with it, so the hint claimed a line of its own. Disabling that one pseudo-element takes the paragraph from 77px to 51px with the caret geometry untouched.

That also explains the red herring: emptying the \n, or making the span inline, both "fix" the height — they remove the block the ::after cannot sit beside. Symptom relief, not the cause.

The fix

-.mu-show-quick-insert-hint .mu-paragraph.mu-active > .mu-paragraph-content:first-of-type::after {
+.mu-show-quick-insert-hint .mu-paragraph.mu-active > .mu-paragraph-content[placeholder]:first-of-type::after {

No box unless there is a hint to show. The :empty::after rule beside it, which renders the "Type / to insert…" hint from empty-hint, is untouched.

Measured

before after
paragraph height after Shift+Enter 77px (3 lines) 51px (2 lines)
caret node geometry top=93 h=26 top=93 h=26 (unchanged)
typing on the new line 第一行\na 第一行\na
empty-paragraph hint "Type / to insert…" unchanged
quick-insert hint after typing / "Search keyword…" unchanged

No DOM change, no change to the DOM ↔ text offset mapping.

Tests

Nothing in the suite looked at layout, so an ::after box quietly taking a line went unnoticed. The new spec compares heights against each other rather than against pixel constants — the bug added a line, and only the ratio between the states says whether it is back — and pins both quick-insert hints, since the fix narrows the selector one of them comes from. Verified to fail with the selector widened again (76.8px where 51.2px is correct) while the hint case kept passing.

Unit suite 216 files / 1475 tests, tsc --noEmit, eslint src test (0 errors), stylelint (no new problems — the one error is pre-existing at blockSyntax.css:940). The ime.spec.ts table-cell case that fails locally fails identically on unmodified develop.

🤖 Generated with Claude Code

https://claude.ai/code/session_01QzDANHQnQyWY3pMWQVR4yB

Jocs and others added 2 commits September 10, 2026 14:52
A paragraph ending in a soft line break rendered one blank line too many
until something was typed on the new line, so the content below it jumped
down and back again.

The quick-insert hint takes `content: attr(placeholder)` from a selector that
never required the attribute, and `placeholder` is only set while the
quick-insert menu is open. The rest of the time the declaration resolved to
an empty string — but the `::after` box was still generated, and an empty box
still takes part in layout. A block ending in a soft line break ends with the
block-level `mu-line-end` span, which an inline box cannot share a line with,
so the hint claimed a line of its own.

Match on the attribute so no box exists unless there is a hint to show. The
`empty-hint` rule beside it is untouched.

Fixes #5282

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01QzDANHQnQyWY3pMWQVR4yB
Nothing in the suite looked at layout, so an `::after` box quietly taking a
line went unnoticed.

The heights are compared against each other rather than against pixel
constants — what the bug did was add a line, and only the ratio between the
states says whether it is back. A second case pins both quick-insert hints,
since the fix narrows the selector one of them comes from.

Verified to fail with the selector widened again (76.8px where 51.2px is
correct, exactly one line) while the hint case kept passing.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01QzDANHQnQyWY3pMWQVR4yB
The hint only renders on a paragraph carrying `mu-active`, which a headless
run does not reliably give it — CI read the zero-width space from
`.mu-content:empty::after` instead and the case failed there while passing
locally.

Set the rule's preconditions directly and toggle the `placeholder` attribute,
which is the contract the fix actually narrowed: a box when the attribute is
there, none when it is not. Verified to fail with the declaration neutered.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01QzDANHQnQyWY3pMWQVR4yB
@Jocs
Jocs merged commit af1ded1 into develop Sep 10, 2026
7 checks passed
@Jocs
Jocs deleted the fix/5282-soft-break-extra-line branch September 10, 2026 07:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] A trailing soft line break renders one blank line too many until you type

1 participant