Skip to content

Fix focus handling when opening the morpheme editor - #178

Merged
alex-rawlings-yyc merged 1 commit into
mainfrom
fix-morph-focus-bug
Jul 28, 2026
Merged

Fix focus handling when opening the morpheme editor#178
alex-rawlings-yyc merged 1 commit into
mainfrom
fix-morph-focus-bug

Conversation

@alex-rawlings-yyc

@alex-rawlings-yyc alex-rawlings-yyc commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Opening the editor now focuses its token and its own input: the morpheme cells no longer let the chip label steal focus, and the panel relies on the popover's open auto-focus, which a mount effect could never do since the portal has no children on that commit.


This change is Reviewable

Summary by CodeRabbit

  • Bug Fixes

    • Improved focus behavior when opening morpheme editors and gloss fields.
    • Prevented clicks on morpheme form cells from unexpectedly moving focus to gloss inputs.
    • Preserved the user’s focus when dismissing an editor by clicking outside.
    • Ensured disabled morphology controls do not trigger focus notifications.
    • Improved popover opening and dismissal behavior for more predictable keyboard and pointer interactions.
  • Tests

    • Added coverage for focus reporting, editor dismissal, and disabled controls.

@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@alex-rawlings-yyc, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 24 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

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

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 550eefda-fa98-4044-8a7e-9b26377edf37

📥 Commits

Reviewing files that changed from the base of the PR and between 0048e54 and 9d1bf8c.

📒 Files selected for processing (8)
  • __mocks__/platform-bible-react.tsx
  • src/__tests__/components/MorphemeBox.test.tsx
  • src/__tests__/components/MorphemeEditor.test.tsx
  • src/__tests__/components/TokenChip.test.tsx
  • src/components/MorphemeBox.tsx
  • src/components/MorphemeEditor.tsx
  • src/components/PhraseBox.tsx
  • src/components/TokenChip.tsx
📝 Walkthrough

Walkthrough

Changes

Morpheme editor interactions now use pointer-specific outside dismissal and portal-timed auto-focus. Gloss inputs report focus through MorphemeBox to TokenChip, while label-driven focus movement is blocked and related tests are expanded.

Morpheme focus flow

Layer / File(s) Summary
Popover portal and pointer-dismissal semantics
__mocks__/platform-bible-react.tsx
The PopoverContent mock delays portal rendering, simulates cancelable auto-focus, and emits pointer-down-outside events.
Morpheme editor dismissal focus behavior
src/components/MorphemeEditor.tsx, src/__tests__/components/MorphemeEditor.test.tsx
Outside pointer dismissal preserves draft handling and prevents focus restoration to the editor field.
Morpheme gloss focus propagation
src/components/MorphemeBox.tsx, src/components/PhraseBox.tsx, src/__tests__/components/MorphemeBox.test.tsx
Gloss focus callbacks are threaded through inputs, non-button cells block label activation, and focus behavior is tested.
TokenChip editor focus integration
src/components/TokenChip.tsx, src/__tests__/components/TokenChip.test.tsx
Morpheme editor opening and gloss focus invoke the chip focus callback, with enabled and disabled cases covered.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant TokenChip
  participant MorphemeBox
  participant MorphemeGlossInput
  TokenChip->>MorphemeBox: open editor with onGlossFocus
  MorphemeBox->>MorphemeGlossInput: pass onFocus callback
  MorphemeGlossInput->>TokenChip: report gloss focus
Loading

Suggested reviewers: imnasnainaec

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: fixing focus behavior when opening the morpheme editor.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-morph-focus-bug

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.

@imnasnainaec imnasnainaec left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@imnasnainaec reviewed 8 files and all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on alex-rawlings-yyc).

Opening the editor now focuses its token and its own input: the morpheme
cells no longer let the chip label steal focus, and the panel relies on
the popover's open auto-focus, which a mount effect could never do since
the portal has no children on that commit.
@alex-rawlings-yyc
alex-rawlings-yyc merged commit 24b9b66 into main Jul 28, 2026
10 checks passed
@alex-rawlings-yyc
alex-rawlings-yyc deleted the fix-morph-focus-bug branch July 28, 2026 19:58
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.

Clicking morpheme buttons focuses respective phrase in sync with opening morpheme editor

2 participants