Skip to content

LT-22691: Answer Jump to field and new-record focus in the New UI - #1261

Merged
mark-sil merged 1 commit into
mainfrom
claude/lt-22691-focus-3e-3f-38da99
Nov 24, 2026
Merged

mark-sil merged 1 commit into
mainfrom
claude/lt-22691-focus-3e-3f-38da99

Conversation

@mark-sil

@mark-sil mark-sil commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

The dictionary preview's Jump to field now lands on the field's row in
the New UI detail view, and on a field of another entry in both detail
views. Until now nothing in the New UI answered it, and in the WinForms
view a field of another entry showed that entry but focused no field.

JumpToField is now published immediately instead of at the end of the
action, and it carries the record to show. The record edit view is its
one subscriber in both views: it has its clerk show the record, then
focuses the row, at once when the record is already shown and otherwise
once it has been. The preview no longer publishes JumpToRecord for this.
The end-of-action publish could run before the record was shown, which
is why a field of another entry was never found. Both views pick the
row by one shared rule.

In the New UI a record its clerk inserts or duplicates, and an entry a
pop-up Lexicon Edit window is asked to show, now open with the keyboard
in their first field, as in the WinForms view. Among the New UI tools
this reaches Insert > Exception Feature in Grammar and Create & Edit
from Notebook's Add to Dictionary. The clerk raises an event beside its
FocusFirstPossibleSlice message, which stays on the Mediator for the
WinForms view.


Reviewer notes

Start here: Src/xWorks/RecordEditView.RowFocus.cs: the Jump to field subscriber, the wait for a record still to be shown, and the rows a new record asks to focus. Then Src/FdoUi/DetailRules/DetailFieldJump.cs, the row-picking rule both views call.

The unknown you start with: "what changed for the WinForms view?" Its row-picking cases moved out of DataTree into DetailFieldJump, with the one difference listed below. And a field of another entry now gets focus. New-record focus in the WinForms view is untouched.

Where to look

  • DetailFieldJump.FindRow holds the cases that were in DataTree.JumpToField. One difference: the grammatical-category case no longer checks the slice's class, because the shared rule may not name a control type. The combo box is the only shipped slice for that field. Pinned by DetailFieldJumpTests.
  • DataTree.JumpToField on a record just shown keeps the request until the end of OnReadyToSetCurrentSlice; another record or a reset drops it. Pinned by two tests in RecordEditViewRowFocusTests.
  • RecordClerk.RecordWantsKeyboard is raised beside each FocusFirstPossibleSlice broadcast the clerk sends, and from OnJumpToPopupRecord only when the jump landed.
  • DetailHostControl.ShowDetail(focusRows) moves the window's keyboard into the Avalonia host only after a row has taken focus. Only the manual runs show that.

Deliberately not here

  • Jump to field made in a pop-up Lexicon Edit window's preview is answered by the main window's view only. The item is offered only while the main tool is Lexicon Edit, where no pop-up opens. A pop-up left open from another tool shows the same entry, and the main window's row takes focus.
  • FocusFirstPossibleSlice stays a Mediator message.
  • WinForms does not focus Name on the first Exception Feature inserted into an empty list. The New UI does; WinForms is unchanged.

Verification

  • build.ps1 -CommentHygiene -TokenHygiene is clean. Targeted runs: xWorksTests 229/229; DetailControlsTests DataTree fixtures 58 passed, 1 skipped (pre-existing NestedCollapsedPart). FdoUiTests 231, FwAvaloniaTests detail 497 and FwUtilsTests Pub/Sub 18 ran before the last DataTree-side change, which touched none of their code. The full suite was not run.
  • Manual runs in Sena 3 passed in both UIs: Jump to field on a headword, a gloss, a grammatical category and a field of another entry. New UI only: the filter prompt answered No and Yes, Insert > Exception Feature into an empty and a non-empty list, and Notebook's Add to Dictionary with Create and Edit.

Next: approve, or name a Jump to field target that lands on the wrong row.

Decisions, and why
  • JumpToField is an immediate publish that carries the record. The end-of-action publish ran from one idle queue and the record show from another, with no order between them. The view now does the sequencing: its clerk shows the record, then the row is focused. No production code calls PublishAtEndOfAction after this.
  • RecordEditView is the one subscriber, for both views. The DataTree no longer subscribes on its own. Each view answers through the same code up to the point of focusing a row.
  • One row-picking rule, in Src/FdoUi/DetailRules. The New UI cannot drift from WinForms, and DetailRulesBoundaryTests keeps control types out of it.
  • New-record focus through a clerk event. In the New UI only three senders can reach it: OnInsertItemInVector (Insert > Exception Feature; the other inserts are answered by dialog listeners first), OnDuplicateSelectedItem (phonological rules, not a New UI tool) and the pop-up jump. Insert > Entry never sent the message: focus stays in the Entries list in both UIs.
  • The WinForms wait belongs to DataTree. Slices just built cannot take focus until they are displayed, and DataTree already defers its own focus to OnReadyToSetCurrentSlice. The request waits on that step, so there is no new idle-queue task and no ordering rule between two classes.
  • Only the main window's view answers Jump to field. A pop-up Lexicon Edit window shares the main window's property table, clerk and Pub/Sub scope, so without the guard both views would answer one request.
Paths not taken
  • Carrying the field on JumpToRecord. The clerk is that message's only subscriber and knows nothing of rows; the detail view would still need its own hand-off.
  • A view-side idle task behind the DataTree's own. It worked, but only while both tasks sat on the same idle queue at different priorities.
  • Converting FocusFirstPossibleSlice to Pub/Sub here. It belongs with the other focus deferrals of the Mediator retirement.
  • Asserting real focus in the view tests. The headless host does not lay out its embedded Avalonia content, so a row never takes focus there. RecordEditView.RowsAskedToFocus is a test seam that records what the view asked for instead; DetailFocusMemoryTests covers the focusing itself.
  • A request that carries the window it came from, so a pop-up's own view could answer. Left out for the reason under "Deliberately not here".
Preflight review details

Code Review Summary

Branch: claude/lt-22691-focus-3e-3f-38da99
Base: main (merge base e29350b; main has since gained #1257, #1255, #1251, #1196 and #1258, which merge cleanly)
Date: 2026-11-24
Review model: Claude Fable 5.2
Files changed: 14 (1 commit)

Overview

Makes the New UI (Avalonia) detail view answer two things only the WinForms DataTree answered
(LT-22691): the dictionary preview's Jump to field, and putting the keyboard in the first field
of a record its clerk inserts or duplicates or a pop-up Lexicon Edit window is asked to show.
Jump to field also now works for a field of another entry in the WinForms view, where it
showed the entry and focused nothing. JumpToField becomes an immediate publish that carries
the record to show; RecordEditView is its one subscriber in both views, and both views pick
the row by one shared rule.

Contract/API Changes

  • EventConstants.JumpToField is published with Publisher.Publish and carries a
    JumpToFieldRequest (record to show, field object, field name, text). It is removed from
    EndOfActionOrder; no production code calls PublishAtEndOfAction any more.
  • XhtmlDocView no longer publishes JumpToRecord for Jump to field.
  • DataTree no longer subscribes to JumpToField; it gains public
    JumpToField(int fieldHvo, string fieldName, string fieldValue), called by RecordEditView.
  • New DetailFieldJump and DetailFieldJumpRow in Src/FdoUi/DetailRules.
  • New internal event RecordClerk.RecordWantsKeyboard.
  • DetailHostControl.ShowDetail gains optional focusRows; new DetailHostControl.FocusRow
    and DetailFocusMemory.ForRows.

Findings

Critical - Must address before merge

None.

Important - Should address before merge

  • Keyboard taken even when no row can take focus (fixed during review: the window's
    keyboard moves into the Avalonia host only once a row has taken focus)
  • Avalonia text match has no exception guard (fixed during review: a failure is logged
    and no row is focused)
  • Queued WinForms jump can apply to another record (fixed during review: the DataTree
    keeps a waiting request with its root and drops it when another root is shown)
  • Event raised when the pop-up jump did not land (fixed during review: raised only when
    the clerk is on the requested record)

Minor - Consider

  • Nested-record ordering in EditorRows is unreachable (fixed during review: removed)
  • DataTree idle-step timing known to RecordEditView (fixed during review: the DataTree
    answers a waiting request at the end of its own ready step; the view queues nothing)
  • Pop-up window's preview jump no longer answered there (the item is offered only while
    the main tool is Lexicon Edit, where no pop-up opens; with a pop-up left open from another
    tool both windows show the same entry and the main window's row takes focus)
  • MSA slice type check dropped from the rule (the shared rule may not name a slice
    class; the combo box is the only shipped slice for that field)
  • RowsAskedToFocus exists only for tests (the headless host does not lay out its
    Avalonia content, so the view tests cannot assert real focus)
  • Sender and window-focus hand-off untested (needs a live preview and a real window;
    covered by the manual runs)

Required Validation / Evidence

  • build.ps1 -CommentHygiene -TokenHygiene succeeded; comment and token hygiene clean.
  • test.ps1 -CommentHygiene -TokenHygiene targeted runs on the committed code: xWorksTests
    229/229 (the record edit view, clerk, menu and command-coverage fixtures); DetailControlsTests
    DataTree fixtures 58 passed, 1 skipped (pre-existing NestedCollapsedPart).
  • Run before the last DataTree-side change, which touched none of their code: FdoUiTests 231,
    FwAvaloniaTests detail fixtures 497, FwUtilsTests Pub/Sub 18.
  • Manual tests in Sena 3, confirmed passed by the author: Jump to field in the New UI and the
    WinForms UI (headword, gloss, grammatical category, a field of another entry, and the filter
    prompt answered No and Yes); Insert > Exception Feature into an empty and a non-empty list;
    Notebook's Add to Dictionary, Create and Edit pop-up; Insert > Entry leaves focus in the
    Entries list in both UIs.
  • Full test suite not run.

Positive Observations

  • The row-picking cases left DataTree for a control-free rule with 21 unit test cases, so the
    two views cannot drift.
  • The cross-entry failure is fixed at its cause (two idle queues with no order between them),
    not by a longer delay.

Interview Notes

  • The author asked that JumpToField stop using PublishAtEndOfAction, and chose the shape
    where it is an ordinary publish and the view has its clerk show the record first, including
    the WinForms DataTree change in this PR.
  • The author chose the DataTree-owned wait over a view-side idle task: it adds no idle-queue
    site and no ordering rule between two classes, which also eases the Mediator retirement.
  • New-record focus goes through a clerk event; the FocusFirstPossibleSlice Mediator message
    is deliberately untouched.
  • The pop-up limit and the RowsAskedToFocus seam were raised and kept by the author.
  • Jira: carries LT-22691.

Suggested Review Focus

  • RecordEditView.RowFocus.cs: the subscriber and the wait for a record still to be shown
  • DetailFieldJump.FindRow against the cases removed from DataTree
  • DataTree.JumpToField and OnReadyToSetCurrentSlice: the waiting request
  • DetailHostControl.ShowDetail(focusRows): when the window keyboard moves

🤖 Generated with Claude Code


This change is Reviewable

The dictionary preview's Jump to field now lands on the field's row in
the New UI detail view, and on a field of another entry in both detail
views. Until now nothing in the New UI answered it, and in the WinForms
view a field of another entry showed that entry but focused no field.

JumpToField is now published immediately instead of at the end of the
action, and it carries the record to show. The record edit view is its
one subscriber in both views: it has its clerk show the record, then
focuses the row, at once when the record is already shown and otherwise
once it has been. The preview no longer publishes JumpToRecord for this.
The end-of-action publish could run before the record was shown, which
is why a field of another entry was never found. Both views pick the
row by one shared rule.

In the New UI a record its clerk inserts or duplicates, and an entry a
pop-up Lexicon Edit window is asked to show, now open with the keyboard
in their first field, as in the WinForms view. Among the New UI tools
this reaches Insert > Exception Feature in Grammar and Create & Edit
from Notebook's Add to Dictionary. The clerk raises an event beside its
FocusFirstPossibleSlice message, which stays on the Mediator for the
WinForms view.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

NUnit Tests

    1 files  ± 0      1 suites  ±0   15m 0s ⏱️ +26s
7 402 tests +38  7 323 ✅ +38  79 💤 ±0  0 ❌ ±0 
7 411 runs  +38  7 332 ✅ +38  79 💤 ±0  0 ❌ ±0 

Results for commit 79495aa. ± Comparison against base commit 44b30f5.

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 82.92683% with 49 lines in your changes missing coverage. Please review.
✅ Project coverage is 40.60%. Comparing base (e29350b) to head (79495aa).
⚠️ Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
Src/xWorks/RecordEditView.RowFocus.cs 84.61% 7 Missing and 7 partials ⚠️
Src/Common/FwAvalonia/DetailHostControl.cs 54.54% 8 Missing and 2 partials ⚠️
Src/FdoUi/DetailRules/DetailFieldJump.cs 92.24% 1 Missing and 8 partials ⚠️
Src/Common/Controls/DetailControls/DataTree.cs 76.92% 3 Missing and 3 partials ⚠️
Src/xWorks/XhtmlDocView.cs 0.00% 5 Missing and 1 partial ⚠️
Src/xWorks/RecordClerk.cs 60.00% 0 Missing and 4 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1261      +/-   ##
==========================================
+ Coverage   40.16%   40.60%   +0.44%     
==========================================
  Files        1597     1601       +4     
  Lines      360084   360728     +644     
  Branches    42148    42239      +91     
==========================================
+ Hits       144633   146481    +1848     
+ Misses     185724   184608    -1116     
+ Partials    29727    29639      -88     
Files with missing lines Coverage Δ
Src/Common/FwAvalonia/Detail/DetailFocusMemory.cs 74.16% <100.00%> (+0.10%) ⬆️
Src/Common/FwUtils/EndOfActionOrder.cs 100.00% <ø> (ø)
...xWorks/Avalonia/Hosting/RecordEditView.Avalonia.cs 67.42% <100.00%> (+0.04%) ⬆️
Src/xWorks/JumpToFieldRequest.cs 100.00% <100.00%> (ø)
Src/xWorks/RecordEditView.cs 63.49% <100.00%> (+1.57%) ⬆️
Src/xWorks/RecordClerk.cs 55.77% <60.00%> (+5.21%) ⬆️
Src/Common/Controls/DetailControls/DataTree.cs 48.41% <76.92%> (+3.29%) ⬆️
Src/xWorks/XhtmlDocView.cs 15.99% <0.00%> (ø)
Src/FdoUi/DetailRules/DetailFieldJump.cs 92.24% <92.24%> (ø)
Src/Common/FwAvalonia/DetailHostControl.cs 58.33% <54.54%> (-2.46%) ⬇️
... and 1 more

... and 65 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@thejambi thejambi 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.

:lgtm:

@thejambi reviewed 14 files and all commit messages, and made 1 comment.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on mark-sil).

@mark-sil
mark-sil merged commit 19f02c1 into main Nov 24, 2026
8 of 9 checks passed
@mark-sil
mark-sil deleted the claude/lt-22691-focus-3e-3f-38da99 branch November 24, 2026 17:27
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.

3 participants