Skip to content

[lexical-playground] Bug Fix: Show the selection's font size again after leaving an emptied font size input - #9969

Open
burrows99 wants to merge 5 commits into
meta:mainfrom
burrows99:fix/font-size-empty-blur
Open

burrows99 wants to merge 5 commits into
meta:mainfrom
burrows99:fix/font-size-empty-blur

Conversation

@burrows99

Copy link
Copy Markdown

Description

In the playground toolbar, clearing the font size input and then clicking back into the text leaves the input empty. It stays empty until the selection's font size changes, and the "Decrease font size" button stays disabled the whole time, because its disabled check reads Number(inputValue) <= MIN_ALLOWED_FONT_SIZE and Number('') is 0.

handleInputBlur already skips applying an empty value, but it never put the selection's size back into the input, and the effect that syncs it only runs when selectionFontSize changes. Leaving an emptied input now shows the selection's size again (and nothing is applied, as before).

flowchart TD
    A[Clear the font size input] --> B{Click back into the text}
    B -->|Before| C[Input stays empty and decrease is disabled]
    B -->|After| D[Input shows the size and decrease works]
Loading

No issue was filed for this; I found it while working in the playground toolbar. It is separate from #9967 (Enter or Escape in an emptied input applying 8px): that one is the keydown path, this one is blur.

Changeset

None: the change is in the playground only (no published package changes).

Test plan

Narrated recording, before then after (sound on):

evidence.mp4

The recording drives the playground dev server (?emptyEditor=false) in headless Chrome: select text, click into the font size input, select its value and delete it, click back into the paragraph, then click "Decrease font size".

Before

The input stays empty and the decrease button stays greyed out; clicking it does nothing.

After

The input shows 16 again and the decrease button works (the input then shows 14).

Edge cases and unchanged behaviour checked

In the running playground (third part of the video):

  • Unchanged: typing 24 in the input and clicking away applies 24px.
  • Edge case: emptying the input and leaving it with Tab shows 16 again.
  • Edge case: emptying the input while 24px text is selected and clicking back into that text shows 24 again (the selection's size, not a default).
  • Unchanged: the decrease button lowers the size of a new selection.

Automated

Added an e2e test to TextFormatting.spec.mjs, "Leaving an emptied font size input shows the selection's font size again". It fails on main (Expected: "16", Received: "") and passes with the fix. The whole TextFormatting.spec.mjs passes in Chromium against the dev server:

playwright test --project=chromium packages/lexical-playground/__tests__/e2e/TextFormatting.spec.mjs
  17 passed

prettier --check and eslint pass on both changed files. I ran Chromium only (locally through the installed Chrome), not Firefox or WebKit, and did not run the full ci-check.

AI assistance (Claude Code) was used to investigate, write and record this change.

🤖 Generated with Claude Code

…ter leaving an emptied font size input

Clearing the toolbar's font size input and clicking away left the input
empty until the selection's font size changed, and the decrease button
stayed disabled because Number('') is 0. Leaving an emptied input now
shows the selection's size again, as nothing is applied.
@vercel

vercel Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
lexical Ready Ready Preview Dec 3, 2026 9:52pm UTC
lexical-playground Ready Ready Preview Dec 3, 2026 9:52pm UTC

Request Review

@rootnode-bot

rootnode-bot Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

AI review status for this pull request.

Review status Updated
🟢 Reviewed (for maintainers only) Dec 3, 2026, 10:11 PM UTC

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Nov 22, 2026

@rootnode-bot rootnode-bot Bot 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.

Thanks, this looks good. The change to handleInputBlur in packages/lexical-playground/src/plugins/ToolbarPlugin/fontSize.tsx is small and correct: an emptied font size field now shows the selection's size again (a non-default size such as 24px too), nothing is applied to the text, and Decrease font size is enabled again. The new e2e test fails on main and passes with the fix.

One suggestion. It doesn't block the fix itself, but I'd apply it before merging, because the extended test suite will otherwise fail on the new test:

  • packages/lexical-playground/__tests__/e2e/TextFormatting.spec.mjs:492 and :499 read the toolbar with page.locator(...). TextFormatting.spec.mjs also runs in the collab e2e modes (rich-text-with-collab and rich-text-with-collab-v2, see .github/workflows/call-e2e-all-tests.yml). In those modes the playground loads inside the left/right iframes of split/, so page.locator('.font-size-input') finds nothing on the outer page and the test times out at line 493 (locator.inputValue: Timeout 10000ms exceeded). The other steps work there because click and fill go through getPageOrFrame(page) in __tests__/utils/index.mjs. The locate helper from the same file fixes it:

    const fontSizeInput = locate(page, '.font-size-input');
    // ...
    await expect(locate(page, '.font-decrement')).toBeEnabled();

    Also add locate to the import from ../utils/index.mjs. With that change the test passes in the rich-text, collab and collab v2 modes.

No changeset is needed: CONTRIBUTING.md exempts playground-only changes.

Automated review (maintainer link)

@pkg-pr-new

pkg-pr-new Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
lexical

npm i https://pkg.pr.new/lexical@9969

@lexical/a11y

npm i https://pkg.pr.new/@lexical/a11y@9969

@lexical/clipboard

npm i https://pkg.pr.new/@lexical/clipboard@9969

@lexical/code

npm i https://pkg.pr.new/@lexical/code@9969

@lexical/code-core

npm i https://pkg.pr.new/@lexical/code-core@9969

@lexical/code-prism

npm i https://pkg.pr.new/@lexical/code-prism@9969

@lexical/code-shiki

npm i https://pkg.pr.new/@lexical/code-shiki@9969

@lexical/compiler

npm i https://pkg.pr.new/@lexical/compiler@9969

@lexical/devtools-core

npm i https://pkg.pr.new/@lexical/devtools-core@9969

@lexical/dragon

npm i https://pkg.pr.new/@lexical/dragon@9969

@lexical/eslint-plugin

npm i https://pkg.pr.new/@lexical/eslint-plugin@9969

@lexical/extension

npm i https://pkg.pr.new/@lexical/extension@9969

@lexical/fast-check

npm i https://pkg.pr.new/@lexical/fast-check@9969

@lexical/file

npm i https://pkg.pr.new/@lexical/file@9969

@lexical/hashtag

npm i https://pkg.pr.new/@lexical/hashtag@9969

@lexical/headless

npm i https://pkg.pr.new/@lexical/headless@9969

@lexical/history

npm i https://pkg.pr.new/@lexical/history@9969

@lexical/html

npm i https://pkg.pr.new/@lexical/html@9969

@lexical/internal

npm i https://pkg.pr.new/@lexical/internal@9969

@lexical/link

npm i https://pkg.pr.new/@lexical/link@9969

@lexical/list

npm i https://pkg.pr.new/@lexical/list@9969

@lexical/mark

npm i https://pkg.pr.new/@lexical/mark@9969

@lexical/markdown

npm i https://pkg.pr.new/@lexical/markdown@9969

@lexical/mdast

npm i https://pkg.pr.new/@lexical/mdast@9969

@lexical/offset

npm i https://pkg.pr.new/@lexical/offset@9969

@lexical/overflow

npm i https://pkg.pr.new/@lexical/overflow@9969

@lexical/plain-text

npm i https://pkg.pr.new/@lexical/plain-text@9969

@lexical/react

npm i https://pkg.pr.new/@lexical/react@9969

@lexical/rich-text

npm i https://pkg.pr.new/@lexical/rich-text@9969

@lexical/selection

npm i https://pkg.pr.new/@lexical/selection@9969

@lexical/table

npm i https://pkg.pr.new/@lexical/table@9969

@lexical/tailwind

npm i https://pkg.pr.new/@lexical/tailwind@9969

@lexical/text

npm i https://pkg.pr.new/@lexical/text@9969

@lexical/utils

npm i https://pkg.pr.new/@lexical/utils@9969

@lexical/y

npm i https://pkg.pr.new/@lexical/y@9969

@lexical/yjs

npm i https://pkg.pr.new/@lexical/yjs@9969

commit: b8f023d

… collab iframe in the emptied input blur test

page.locator only searches the top-level page; in the collab e2e modes the
toolbar is inside the split view's iframe. Use locate() like the click and
fill steps.

@rootnode-bot rootnode-bot Bot 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.

Thanks, this looks good. Leaving an emptied font size field now puts the selection's size back (24 when the caret is in 24px text, not just the 16px default), nothing is applied to the text, and Decrease font size is enabled again. The new branch in handleInputBlur (packages/lexical-playground/src/plugins/ToolbarPlugin/fontSize.tsx:98-101) only resets the field's own state, so an empty blur still writes nothing to the editor.

The switch to locate(page, …) in packages/lexical-playground/__tests__/e2e/TextFormatting.spec.mjs (lines 493 and 500) resolves the earlier note about the collab e2e modes: the new test now finds the toolbar inside the collab iframe. It fails without the fix (Expected: "16", Received: "") and passes with it in the rich-text, collab and collab v2 modes.

No changeset is needed: AGENTS.md and CONTRIBUTING.md exempt playground-only changes. If the Changesets check asks for one once the workflows are approved, a maintainer can apply the skip-changeset label.

Automated review (maintainer link)

@rootnode-bot rootnode-bot Bot 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.

This looks good, thanks for tracking it down, and for switching the test to locate() so it also runs in the collab modes.

Leaving an emptied font size field now refills it from the selection's size (packages/lexical-playground/src/plugins/ToolbarPlugin/fontSize.tsx:98-101) without writing anything to the editor, and clearing inputChangeFlag there also stops a later blur from re-applying the restored size. The new e2e test covers the reported path and passes in the Chromium and Firefox rich-text and collab runs.

One optional, non-blocking suggestion:

  • The test could tell the selection's size from the default (packages/lexical-playground/__tests__/e2e/TextFormatting.spec.mjs:494). The expected value is read from the field while the selection is at the default 16px, so a blur that restored the default size instead of the selection's size would also pass. Your manual 24px check is the case that separates them: applying 24px to the selection first and expecting '24' after leaving the emptied field (or at least expecting a literal '16') would pin that behavior in the test.

No changeset is needed: AGENTS.md and CONTRIBUTING.md exempt playground-only changes.

Automated review (maintainer link)

…e in the emptied input blur test

Apply 18px to the selection first and leave the field with blur(), so a blur that restored a default 16px instead of the selection's size would fail.

@rootnode-bot rootnode-bot Bot 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.

Thanks, this change looks good. Leaving an emptied font size field now puts the selection's size back, still without applying anything, so Decrease font size works again. The new e2e test catches the bug: run locally, it fails on main with Expected: "18", Received: "" and passes on this branch in the rich-text, collab and collab-v2 modes.

One optional, non-blocking suggestion:

  • The Test plan quotes a stale failure: the description says the test "fails on main (Expected: "16", Received: "")", but since a7eb21a it expects '18' (packages/lexical-playground/__tests__/e2e/TextFormatting.spec.mjs:497 and :503), so on main it now fails with Expected: "18". AGENTS.md ("Commits and Pull Requests") also asks for the command you ran and its real output under ### Before and ### After. Pasting the Playwright failure and pass there would fix both.

No changeset is needed, as the description says: AGENTS.md and CONTRIBUTING.md exempt playground-only changes. This branch and #9967 (the Enter/Escape path in the same component) also merge cleanly with each other.

Automated review (maintainer link)

This branch was successfully deployed

2 active deployments
Preview – lexical — a7eb21ac Deployed Dec 3, 2026 by vercel[bot]
Preview – lexical-playground — a7eb21ac Deployed Dec 3, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants