Skip to content

Fix LT-22427: Show Hidden Fields reveals Inflection Class/Features in Lexicon Edit#690

Open
johnml1135 wants to merge 3 commits intomainfrom
LT-22427
Open

Fix LT-22427: Show Hidden Fields reveals Inflection Class/Features in Lexicon Edit#690
johnml1135 wants to merge 3 commits intomainfrom
LT-22427

Conversation

@johnml1135
Copy link
Contributor

@johnml1135 johnml1135 commented Feb 20, 2026

Fix LT-22427: Show Hidden Fields in Lexicon Edit

Problem

When Show Hidden Fields was enabled in Lexicon Edit, the visibility="ifdata" fields under Grammatical Info. Details — Inflection Class, Inflection Features, and Exception "Features" — did not appear, even though they should become visible when the user toggles this option.

Additionally, "Attaches to Categories" (visibility="always") was also hidden because its parent section stayed collapsed.

Root Causes (three independent issues)

1. Inconsistent property key resolution

GetShowHiddenFieldsToolName() did not normalize the key for ILexEntry roots. When currentContentControl was "lexiconBrowse" or "lexiconDictionary", the show-hidden toggle would write to the wrong property key, making it ineffective.

2. SliceFilter blocking fields even with Show Hidden Fields ON

ProcessSubpartNode checked the SliceFilter (which calls IsFieldRelevant) unconditionally. When no POS was set, IsFieldRelevant returned false for InflectionClass, hiding it even when the user explicitly asked to see hidden fields.

3. Parent slices staying collapsed

The "Category Info." parent slice (an MSADlgLauncherSlice) had no expansion="expanded" XML attribute and no persisted expansion state. When all its ifdata children were hidden (no data), the parent collapsed to ktisFixed. Even after fixes 1 & 2 made the children logically visible, the parent never expanded to show them. This also hid "Attaches to Categories" (visibility="always"), which should always have been visible when the parent is expanded.

Fixes

Commit 1: GetShowHiddenFieldsToolName unification (b1c80fc)

Introduced a single helper that normalizes the property key to "lexiconEdit" for all ILexEntry roots, regardless of currentContentControl. Applied across ShowObject, OnDisplayShowHiddenFields, and OnPropertyChanged.

Commit 2: SliceFilter bypass + parent auto-expand (f4f84a9)

  • SliceFilter bypass: Added !m_fShowAllFields && guard before the SliceFilter check in ProcessSubpartNode. When Show Hidden Fields is ON, the filter is bypassed so fields hidden by IsFieldRelevant still appear.
  • Parent auto-expand: In Slice.GenerateChildren, when ShowingAllFields is true, force fExpand = true so parent slices expand to reveal their now-visible children.
  • Dead code removal: Removed unreachable if (candidateRoot is ILexEntry) fallback in GetShowHiddenFieldsToolName.
  • Added explanatory comment on why ILexEntry always maps to "lexiconEdit".

Why "Attaches to Categories" now appears

FromPartsOfSpeech is defined with visibility="always" in the MoStemMsa Normal layout — it was never a hidden field. It was invisible only because its parent (Category Info.) stayed collapsed when all its ifdata siblings had no data. The auto-expand fix correctly reveals it alongside the hidden fields. This is correct behavior.

Files Changed

File Change
Src/Common/Controls/DetailControls/DataTree.cs SliceFilter bypass in ProcessSubpartNode; dead code removal + comment in GetShowHiddenFieldsToolName
Src/Common/Controls/DetailControls/Slice.cs Auto-expand parent when ShowingAllFields is true
Src/Common/Controls/DetailControls/DetailControlsTests/DataTreeTests.cs 8 new tests
Src/Common/Controls/DetailControls/DetailControlsTests/Test.fwlayout 2 new test layouts (ParentWithHiddenChildren, CfAndBibFiltered)
Src/Common/Controls/DetailControls/DetailControlsTests/TestParts.xml 1 new test part (BibliographyFiltered)

Tests Added

Test What it validates
ShowObject_ShowHiddenEnabledForCurrentTool_ShowsIfDataSlicesForLexEntry Regression test: ifdata slices appear with ShowHiddenFields ON
ShowObject_NoCurrentContentControl_FallsBackToLexiconEditForLexEntry Backward compat: null currentContentControl falls back to lexiconEdit
ShowObject_NonLexiconCurrentContentControl_UsesLexiconEditForLexEntry Non-lexicon tool still resolves to lexiconEdit for ILexEntry
ShowObject_ShowHiddenForDifferentTool_DoesNotRevealIfDataSlices Cross-tool isolation: wrong tool key doesn't reveal fields
ShowObject_ShowHiddenEnabled_RevealsNeverVisibilityParts Documents: visibility="never" parts also become visible
ShowObject_ShowHiddenEnabled_BypassesSliceFilter SliceFilter is bypassed when ShowHiddenFields ON
ShowObject_ShowHiddenFields_ExpandsParentToRevealChildren TDD test: parent auto-expands to reveal ifdata children
OnPropertyChanged_ShowHiddenFields_TogglesForCurrentTool View menu toggle writes correct property key
OnDisplayShowHiddenFields_CheckedState_MatchesCurrentTool Menu check-mark reads correct property key

Test Results

19 DataTree tests: 18 passed, 1 skipped (pre-existing NestedCollapsedPart).

The TDD test (ShowObject_ShowHiddenFields_ExpandsParentToRevealChildren) was verified to:

  • Fail without the fix (Expected: 2, But was: 1)
  • Pass with the fix

This change is Reviewable


This change is Reviewable

Copilot AI review requested due to automatic review settings February 20, 2026 18:14
@github-actions

This comment has been minimized.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes LT-22427 by ensuring “Show Hidden Fields” is keyed consistently to the active tool name when rendering Lexicon entry details, preventing visibility="ifdata" slices (e.g., “Inflection Features”) from being incorrectly hidden.

Changes:

  • Introduced GetShowHiddenFieldsToolName(...) in DataTree and applied it across ShowObject(), OnDisplayShowHiddenFields(), and OnPropertyChanged("ShowHiddenFields") to unify tool-name resolution.
  • Added regression + coverage tests around tool-specific show-hidden behavior and fallback behavior for ILexEntry.
  • Updated VS Code/worktree workspace settings to open FieldWorks.sln more deterministically (ReSharper + dotnet settings).

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
Src/Common/Controls/DetailControls/DataTree.cs Unifies show-hidden tool name resolution via a helper and applies it at all relevant call sites.
Src/Common/Controls/DetailControls/DetailControlsTests/DataTreeTests.cs Adds tests covering the regression and the three previously-inconsistent code paths.
scripts/Setup-WorktreeColor.ps1 Adds managed workspace settings for solution opening behavior in generated worktree workspaces.
.vscode/settings.json Adjusts ReSharper solution auto-open behavior to avoid reopening stale solutions when switching worktrees.

@johnml1135 johnml1135 force-pushed the LT-22427 branch 2 times, most recently from a30736b to b1c80fc Compare February 20, 2026 18:28
@github-actions
Copy link

github-actions bot commented Feb 20, 2026

NUnit Tests

    1 files  ±0      1 suites  ±0   6m 18s ⏱️ -14s
4 416 tests +9  4 329 ✅ +9  87 💤 ±0  0 ❌ ±0 
4 425 runs  +9  4 338 ✅ +9  87 💤 ±0  0 ❌ ±0 

Results for commit 34d4ba2. ± Comparison against base commit cb374e2.

♻️ This comment has been updated with latest results.

@jasonleenaylor
Copy link
Contributor

@johnml1135 @copilot doesn't seem to have identified the true root cause and is instead adding a hack to fix the issue.

Copy link
Contributor

Copilot AI commented Feb 23, 2026

@jasonleenaylor I've opened a new pull request, #701, to work on those changes. Once the pull request is ready, I'll request review from you.


// ifdata slices should now be visible.
Assert.That(m_dtree.Controls.Count, Is.EqualTo(2), "After toggle: ifdata slice should appear");
Assert.That((m_dtree.Controls[1] as Slice).Label, Is.EqualTo("Bibliography"));
Copy link
Contributor

Choose a reason for hiding this comment

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

check second control

Copy link
Contributor

@papeh papeh left a comment

Choose a reason for hiding this comment

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

Oops, didn't see @jasonleenaylor's comment before approving. Rescinding my approval.

@johnml1135 johnml1135 changed the title Fix LT-22427: "Inflection Features" hidden field no longer appears in Lexicon Edit Fix LT-22427: Show Hidden Fields reveals Inflection Class/Features in Lexicon Edit Feb 25, 2026
@johnml1135
Copy link
Contributor Author

johnml1135 commented Feb 25, 2026

I think Copilot did a better job now - check again. It also found "another" field "Attaches to categories"- should it show up?
image

Unify DataTree show-hidden key resolution across ShowObject,
menu display, and property change handling.
Use currentContentControl when present; fall back to
lexiconEdit for LexEntry.

Add regression tests for LexEntry ifdata slice visibility
when show-hidden is enabled for the active tool.

Add commit-messages.instructions.md for agent guidance.
New skill orchestrates the full JIRA bugfix lifecycle:
fetch issue, assign, branch, TDD, fix, assess coverage,
devil's advocate review, update AGENTS.md, commit, PR,
and update JIRA.

Includes a devil's advocate step that critically reviews
the fix and surfaces uncertainties for user decision.

Register the skill in both AGENTS.md files.
When Show Hidden Fields is enabled for Lexicon Edit,
bypass the SliceFilter so fields hidden by
IsFieldRelevant (e.g. InflectionClass with no POS)
still appear. Auto-expand parent slices whose children
were previously all hidden, so newly visible fields
are not trapped behind a collapsed parent.

This also fixes Attaches to Categories (visibility=
always) being hidden when the Category Info parent
stayed collapsed because all its ifdata siblings had
no data.

Remove unreachable dead-code branch in
GetShowHiddenFieldsToolName. Add unit tests for
SliceFilter bypass and parent auto-expand.
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.

5 participants