Skip to content

Keep slides text-box in edit mode when clicking toolbar controls#301

Merged
hackerwins merged 1 commit into
mainfrom
fix/slides-textbox-toolbar-focus
May 25, 2026
Merged

Keep slides text-box in edit mode when clicking toolbar controls#301
hackerwins merged 1 commit into
mainfrom
fix/slides-textbox-toolbar-focus

Conversation

@hackerwins

Copy link
Copy Markdown
Collaborator

Summary

In the Slides text-box edit mode, clicking a formatting toolbar control (reported: the bullet-list icon) did not apply the action and instead dropped the user out of text editing entirely.

Root cause: the slides text box reuses the docs initializeTextBox, whose hidden <textarea> commits + detaches on any blur. Clicking a toolbar control steals focus on mousedown, so the commit+detach (onCommitfinishEditMode()) runs before the control's React onClick — the toggle is applied to an already-detached editor and edit mode collapses. Docs is immune because its main editor is always mounted.

Two distinct trigger classes, fixed with the canonical mechanism for each:

  • Direct buttons / toggles (bullet, numbered, indent/outdent, link, bold/italic/underline/strike) → onMouseDown preventDefault() so the textarea never blurs (no commit/detach, focus retained for continued typing).
  • Dropdowns (block style, alignment, text/highlight color) → a trigger-level preventDefault can't help because Radix focuses menu items on pointer hover (@radix-ui/react-menu MenuItemImpl.onPointerMove). Instead the docs text-box handleBlur skips the commit when relatedTarget is inside a data-text-edit-keepalive element; dropdown triggers + content carry that marker, and content prevents close-auto-focus so the box stays focused after a selection.

Scope: initializeTextBox is slides-only (the docs main editor uses text-editor.ts), so the handleBlur change does not affect the docs editor. The data-text-edit-keepalive attributes / onCloseAutoFocus are inert (and mildly beneficial) in the docs toolbar.

Test plan

  • pnpm verify:fast — green (EXIT=0).
  • New regression tests:
    • packages/docs/test/view/text-box-editor.test.ts (editor-side guard): blur into a [data-text-edit-keepalive] control (button + menu-item descendant) does not commit; a genuine outside blur still commits.
    • packages/frontend/tests/components/text-formatting/toolbar-focus.test.ts (React layer): renders the three shared groups in jsdom; asserts the 9 direct buttons/toggles preventDefault mousedown, that the bullet click still calls toggleList('unordered'), and that the 3 dropdown triggers carry data-text-edit-keepalive.
  • Manual smoke (pnpm dev): entered a slides text box → bullet/numbered/indent/bold/link all apply and stay in edit mode; style/alignment/text-color/highlight dropdowns apply and keep editing.

🤖 Generated with Claude Code

The slides text box reuses the docs initializeTextBox, which commits and
detaches on any textarea blur. Clicking a formatting toolbar control stole
focus on mousedown, so the commit+detach ran BEFORE the control's onClick —
the action (e.g. the bullet-list toggle) never applied and edit mode
collapsed entirely.

Direct buttons/toggles now preventDefault their mousedown so the textarea
never blurs. Dropdowns can't rely on that (Radix focuses menu items on
pointer hover), so the docs text-box blur handler skips the commit when
focus moves into a [data-text-edit-keepalive] element; dropdown triggers
and content carry that marker, and content prevents close-auto-focus so
the box stays focused after a selection.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@coderabbitai

coderabbitai Bot commented May 25, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@hackerwins, we couldn't start this review because you've used your available PR reviews for now.

Your plan includes 1 review of capacity. Refill in 32 minutes and 29 seconds.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more review capacity refills, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than trial, open-source, and free plans. In all cases, review capacity refills continuously over time.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 871e3377-d011-4f0f-b163-b83c77d75a56

📥 Commits

Reviewing files that changed from the base of the PR and between 5db952b and 5744994.

📒 Files selected for processing (9)
  • docs/tasks/README.md
  • docs/tasks/active/20260525-slides-textbox-toolbar-focus-lessons.md
  • docs/tasks/active/20260525-slides-textbox-toolbar-focus-todo.md
  • packages/docs/src/view/text-box-editor.ts
  • packages/docs/test/view/text-box-editor.test.ts
  • packages/frontend/src/components/text-formatting/text-format-group.tsx
  • packages/frontend/src/components/text-formatting/text-paragraph-group.tsx
  • packages/frontend/src/components/text-formatting/text-style-group.tsx
  • packages/frontend/tests/components/text-formatting/toolbar-focus.test.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/slides-textbox-toolbar-focus

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@hackerwins
hackerwins merged commit 4349498 into main May 25, 2026
1 check passed
@hackerwins
hackerwins deleted the fix/slides-textbox-toolbar-focus branch May 25, 2026 15:51
@github-actions

github-actions Bot commented May 25, 2026

Copy link
Copy Markdown
Contributor

Verification: verify:self

Result: ✅ PASS in 230.8s

Lane Status Duration
tokens:build ✅ pass 2.5s
sheets:build ✅ pass 12.4s
docs:build ✅ pass 12.1s
slides:build ✅ pass 13.7s
verify:fast ✅ pass 146.9s
frontend:build ✅ pass 18.5s
verify:frontend:chunks ✅ pass 0.3s
backend:build ✅ pass 4.9s
cli:build ✅ pass 2.1s
verify:entropy ✅ pass 17.5s

Verification: verify:integration

Result: ✅ PASS

@codecov

codecov Bot commented May 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

hackerwins added a commit that referenced this pull request May 31, 2026
PRs #257/#301/#303/#304/#305/#306/#307/#309/#315/#316/#317/#321/#322
shipped between v0.4.2 and the v0.4.3 cut, leaving their paired todo
files in active with the process checkboxes still open. Flip the
remaining boxes for the work that landed, then move the paired
todo/lessons into docs/tasks/archive/2026/05/ via pnpm tasks:archive.
Active count drops from 17 to 6; archive count grows by 21 files.

Patch release covering 29 commits since v0.4.2. Headline theme is
Slides editing & UX polish toward Google Slides / PowerPoint parity:
smart guides (equal-spacing / distance / size), Shift drag modifiers,
text inside shapes, a Format options right panel, tier-1 universal
toolbar controls, text autofit (shrink + grow), group-selection
visuals, and several smaller text-box / selection fixes. PPTX import
gained paragraph-level bullet styles, body anchor (vertical
alignment), and stretched blipFill cover-crop.

Docs added a pending-inline-style at collapsed caret, a caret that
tracks the resolved text color, bullet indent on Tab / Shift+Tab,
font / size / line-spacing / clear formatting toolbar controls, an
inline-style-attribute clear that actually lands in the CRDT, and a
polished toolbar trigger / color swatch pass shared across docs /
sheets / slides. Sheets gained .xlsx import.

Infrastructure: Docker images now build on native arm64 runners,
fixing the release hang seen on v0.4.2. No Prisma migration, no new
backend env vars — the devops bump is a routine image-tag change.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
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.

1 participant