Skip to content

fix(focus-zone): preserve input editing inside active zones#302

Merged
RtlZeroMemory merged 2 commits intomainfrom
fix/focus-zone-input-precedence
Mar 19, 2026
Merged

fix(focus-zone): preserve input editing inside active zones#302
RtlZeroMemory merged 2 commits intomainfrom
fix/focus-zone-input-precedence

Conversation

@RtlZeroMemory
Copy link
Copy Markdown
Owner

@RtlZeroMemory RtlZeroMemory commented Mar 19, 2026

Summary

Focused text inputs inside active focus zones now keep arrow-key editing priority, and the focus-zone docs now clarify the existing multi-child layout fallback.

Problem

Active focus-zone routing ran before shared input editing, so focused inputs and textareas inside an active zone could lose arrow-key editing to zone traversal.

Root cause

routeEngineEvent handled generic zone key routing before handing key events to the shared input editor, which let active zones consume arrow navigation intended for text editing.

Fix

Route focused input key editing before generic zone routing, keep the existing zone traversal path for non-text widgets, add regressions for input and textarea editing inside active zones, and clarify the single-child transparency versus legacy multi-child column fallback in the docs.

Tests

npm run lint
npm run typecheck
npm run build
node scripts/run-tests.mjs --filter "widgetRenderer.integration.test.js"
node scripts/run-tests.mjs --filter "focus.zones.test.js"
node scripts/run-tests.mjs --filter "layout.focusZone.test.js"
node scripts/run-tests.mjs

Notes

No zone-navigation redesign is included here; this only changes precedence so focused text editing wins inside active zones.

Summary by CodeRabbit

  • Documentation

    • Clarified focusZone layout behavior: it's layout‑transparent only with a single child; guidance and examples now show using explicit row/column/grid wrappers for multi-child layouts and updated navigation samples.
  • Bug Fixes

    • Improved focus retention during text editing so keyboard navigation keys no longer steal focus from active input or textarea.
  • Tests

    • Added integration tests validating focus stability and correct text input handling when navigation keys are pressed during editing.

@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 19, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 265db960-70ce-4db5-825d-c49021a2851f

📥 Commits

Reviewing files that changed from the base of the PR and between a0d2c3b and 7465bdd.

📒 Files selected for processing (1)
  • docs/widgets/focus-zone.md
✅ Files skipped from review due to trivial changes (1)
  • docs/widgets/focus-zone.md

📝 Walkthrough

Walkthrough

Documentation clarifies focusZone layout behavior for single vs. multiple children; two integration tests ensure focus retention during text editing in input and textarea widgets; event routing now handles key events early via routeInputEditingEvent to avoid duplicate processing.

Changes

Cohort / File(s) Summary
Documentation
docs/widgets/focus-zone.md
Clarified that focusZone is layout-transparent only when wrapping a single child and documents legacy column fallback for multiple direct children; examples updated to use explicit ui.row/ui.column/ui.grid wrappers.
Event Routing
packages/core/src/app/widgetRenderer/routeEngineEvent.ts
routeEngineEventImpl now calls routeInputEditingEvent early for event.kind === "key" and returns immediately when it yields an InputEditingRoutingOutcome; removed duplicate fallback invocation for key events.
Integration Tests
packages/core/src/app/__tests__/widgetRenderer.integration.test.ts
Added two tests verifying ui.focusZone retains focus during active text editing: single-line ui.input with LEFT navigation and multi-line ui.textarea with UP navigation; assert emitted action: "input" payloads and onInput callbacks receive updated values and cursor positions.

Sequence Diagram(s)

sequenceDiagram
    participant Client as User / Client
    participant Engine as RouteEngine
    participant InputRouter as routeInputEditingEvent
    participant KeyRouter as routeKeyWithZones
    participant Widget as Widget/onInput
    participant Router as RoutingEmitter

    Client->>Engine: key event (kind: "key")
    Engine->>InputRouter: routeInputEditingEvent (early)
    alt InputRouter handles as InputEditingOutcome
        InputRouter->>Router: emit action: "input" (payload)
        Router->>Widget: onInput callback with updated value + cursor
        Engine-->>Client: stop further routing (return)
    else Not handled
        Engine->>KeyRouter: routeKeyWithZones (fallback)
        KeyRouter->>Engine: routing outcome (focus change or other)
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Poem

🐰
I hop where focus stays in line,
Keys routed early, edits fine.
Inputs keep their caret true,
Tests and docs say what I do.
A little hop — the widgets chew!

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix(focus-zone): preserve input editing inside active zones' accurately reflects the core change: fixing a routing order issue so text input editing within focus zones maintains priority over zone navigation.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/focus-zone-input-precedence
📝 Coding Plan
  • Generate coding plan for human review comments

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

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@docs/widgets/focus-zone.md`:
- Around line 25-27: The examples still show multiple direct children (which now
trigger a legacy column fallback); update the opening usage example, the
navigation examples, and the grid example to wrap multi-child zones in explicit
layout widgets (e.g., Column, Row, or a Grid container) instead of providing
siblings directly so the docs reflect the new guidance about avoiding direct
multi-child zones and no longer imply the legacy column fallback.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: faa8440d-a2cb-4ad6-ae81-8233376a46de

📥 Commits

Reviewing files that changed from the base of the PR and between 890337d and a0d2c3b.

📒 Files selected for processing (3)
  • docs/widgets/focus-zone.md
  • packages/core/src/app/__tests__/widgetRenderer.integration.test.ts
  • packages/core/src/app/widgetRenderer/routeEngineEvent.ts

@RtlZeroMemory RtlZeroMemory merged commit b38cac6 into main Mar 19, 2026
31 of 32 checks passed
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