Fix the writing system drop down not tracking reversal fields - #1121
Open
mark-sil wants to merge 1 commit into
Open
Fix the writing system drop down not tracking reversal fields#1121mark-sil wants to merge 1 commit into
mark-sil wants to merge 1 commit into
Conversation
Avalonia text editors built by SliceFactory receive the host's writing-system focus callback, so the toolbar ws combo follows the cursor. Plugin-built rows never did: SlicePluginBuildContext carried no callback, and ReversalIndexEntryPlugin substituted a keyboard-only lambda, so focusing a reversal form switched the keyboard but published nothing. In FLEx's New lexical edit UI, clicking into a Reversal Entries form left the toolbar writing-system combo showing whichever writing system the previous field had, even though the keyboard switched. Users saw Sena selected while typing into an English or Portuguese reversal form. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1121 +/- ##
==========================================
- Coverage 38.56% 38.55% -0.01%
==========================================
Files 1513 1513
Lines 350995 351003 +8
Branches 40350 40350
==========================================
- Hits 135351 135334 -17
- Misses 186427 186449 +22
- Partials 29217 29220 +3
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In the New lexical edit UI, clicking into a Reversal Entries form now moves the toolbar writing-system combo to that form's writing system, the same way every other text field already does. Before, the keyboard switched but the combo kept showing the previous field's writing system.
Why it was broken. Editors built by SliceFactory receive the host's writing-system focus callback. Plugin-built rows never did:
SlicePluginBuildContextcarried no callback, soReversalIndexEntryPluginsubstituted its own keyboard-only lambda and nothing publishedWritingSystemUnderCursorChanged. The fix hands the plugin the host's real callback. The question worth a reviewer's time is not "what breaks" (nothing changes for composer-built rows) but whether the callback enters at the right layer, which is covered below.Where to look
RecordEditView.ShowAvaloniaEntry: two named arguments passOnDetailWritingSystemFocusedintoCompose. This is the only production wiring, and the only touch on that file.DetailComposer: optional trailing parameter on bothComposeoverloads andComposeState, passed into the plugin build context. Parameter plumbing only.SlicePluginBuildContext.WritingSystemFocused: the new seam plugins read.ReversalIndexEntryPlugin: forwards the context callback and drops its private keyboard-only fallback, so keyboard activation and the publish come from one path.DetailWritingSystemStateTests: the new test composes with the host handler, realizes the view headless, focuses the reversal editor, and asserts the toolbar'sWritingSystemHvoproperty moved through Pub/Sub andWritingSystemListHandler.Deliberately not here
DetailField.ControlFactory, to keep clear of PR Use project .fwlayout files for Avalonia persistence #1111's rewrite ofDetailModel.cs. See the accordion.RecordEditViewarguments are covered by manual test, not by the test.Verification.
build.ps1 -CommentHygiene -TokenHygienegreen. Targetedtest.ps1over the ws-state, plugin inventory, and reversal composer fixtures: 11/11. Manual check in Sena 3 (New UI mode): combo follows the cursor into the Portuguese and English reversal forms. Full suites not run. Two pre-existing reversal composer tests were order-dependent (no headless platform init) and now pass in isolation.Design: compose-time threading vs the ControlFactory seam
SliceFactory.CreateCustomalready holds aSliceFactoryContextwith the host callback when it invokes a plugin's factory, so the architecturally purest fix would pass that context throughDetailField.ControlFactory. That changes the delegate type inDetailModel.cs, which PR #1111 rewrites heavily along withDetailComposer.cs. Compose-time threading keeps the #1111 overlap to parameter-list additions.Consequences accepted for now: the callback lives in two places (Compose and the DataTree constructor), both fed by the same method group in
RecordEditView; and further host services for plugins (menu, clipboard) would repeat the same plumbing. The render-time seam is the target once #1111 lands.Decision: the plugin's keyboard-only fallback is gone
The plugin used to call
WritingSystemKeyboards.Activateitself. The host callback already does that and also publishes, so keeping a fallback would double-activate. Without a host callback the plugin row now behaves exactly like every composer-built row (no keyboard switching). No production or preview host composes plugin rows without the callback; the only such callers are tests that do not assert on keyboard behavior.Preflight review details
Eight-angle review with one verifier per candidate: nine candidates, seven confirmed, two refuted.
Fixed before commit:
<param>and consumer-narrating property summary onSlicePluginBuildContext.Compose<param>trimmed to its value contract.DetailComposerTests.TestSetup(both reversal tests pass alone).ReversalIndexEntryPlugin.DefaultAutomationId.Accepted as is: the new test supplies the host handler to
Composeitself; the host's two named arguments are covered by manual test.Refuted: dual injection points drifting (no callback-less host composes plugin rows); dropping the fallback (parity with composer rows).
Contract changes: optional trailing parameters only, plus one new public constant. No Critical or Important findings.
CI-ready checklist
.github/commit-guidelines.md.build.ps1andtest.ps1.pr-preflightran before requesting review.AGENTS.mdunder the touchedSrc/**folders needs updating.🤖 Generated with Claude Code
This change is