Repository navigation
Conversation
…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.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
There was a problem hiding this comment.
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:492and:499read the toolbar withpage.locator(...).TextFormatting.spec.mjsalso runs in the collab e2e modes (rich-text-with-collabandrich-text-with-collab-v2, see.github/workflows/call-e2e-all-tests.yml). In those modes the playground loads inside theleft/rightiframes ofsplit/, sopage.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 becauseclickandfillgo throughgetPageOrFrame(page)in__tests__/utils/index.mjs. Thelocatehelper from the same file fixes it:const fontSizeInput = locate(page, '.font-size-input'); // ... await expect(locate(page, '.font-decrement')).toBeEnabled();
Also add
locateto 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.
lexical
@lexical/a11y
@lexical/clipboard
@lexical/code
@lexical/code-core
@lexical/code-prism
@lexical/code-shiki
@lexical/compiler
@lexical/devtools-core
@lexical/dragon
@lexical/eslint-plugin
@lexical/extension
@lexical/fast-check
@lexical/file
@lexical/hashtag
@lexical/headless
@lexical/history
@lexical/html
@lexical/internal
@lexical/link
@lexical/list
@lexical/mark
@lexical/markdown
@lexical/mdast
@lexical/offset
@lexical/overflow
@lexical/plain-text
@lexical/react
@lexical/rich-text
@lexical/selection
@lexical/table
@lexical/tailwind
@lexical/text
@lexical/utils
@lexical/y
@lexical/yjs
commit: |
… 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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
…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.
There was a problem hiding this comment.
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:497and:503), so onmainit now fails withExpected: "18". AGENTS.md ("Commits and Pull Requests") also asks for the command you ran and its real output under### Beforeand### 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.
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
disabledcheck readsNumber(inputValue) <= MIN_ALLOWED_FONT_SIZEandNumber('')is0.handleInputBluralready 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 whenselectionFontSizechanges. 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]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
16again and the decrease button works (the input then shows14).Edge cases and unchanged behaviour checked
In the running playground (third part of the video):
24in the input and clicking away applies 24px.16again.24again (the selection's size, not a default).Automated
Added an e2e test to
TextFormatting.spec.mjs, "Leaving an emptied font size input shows the selection's font size again". It fails onmain(Expected: "16",Received: "") and passes with the fix. The wholeTextFormatting.spec.mjspasses in Chromium against the dev server:prettier --checkandeslintpass on both changed files. I ran Chromium only (locally through the installed Chrome), not Firefox or WebKit, and did not run the fullci-check.AI assistance (Claude Code) was used to investigate, write and record this change.
🤖 Generated with Claude Code