Skip to content

fix(windows): open each data grid edit in a new TextBox so it never takes the last cell's height - #4380

Merged
datlechin merged 3 commits into
mainfrom
fix/windows-grid-wrap-off-editor
Nov 20, 2026
Merged

datlechin merged 3 commits into
mainfrom
fix/windows-grid-wrap-off-editor

Conversation

@datlechin

Copy link
Copy Markdown
Member

Summary

  • The data grid reused one TextBox for every cell edit.
  • WinUI's TextBox animates its own Height for 100 ms when its size changes while it has focus, has no Height, and wraps or takes returns. When the animation ends it sets Height to NaN (TextBox::OnSizeChanged, dxaml/xcp/dxaml/lib/TextBox_Partial.cpp).
  • So an edit after a taller wrapped cell opened at that cell's height. A one-line editor then lost the grid's Height when the animation ended. This kept TheEditorCoversAWrappedRowAndWrapsItsTextAndWithWrapOffIsOneRowAgain from feat(datagrid): wrap long values onto several lines in the data grid #4378 failing on main.
  • Each edit now opens a new TextBox. Loaded, LostFocus and TextChanged act only for the current box, since they can arrive late from the last one.
  • The new box takes focus as it opens, not on Loaded. WinUI needs it in the tree, not loaded (CUIElement::IsFocusable), so keys typed right after F2 or Tab reach it. Loaded focuses only a box still without focus, so it never selects over typed text.
  • ADR 0003, Editing, records both, with the probe run.

Test plan

  • New EachEditOpensAtItsOwnRowsHeightAfterATallerOne. On main the reused box measured 74 to 89 px there instead of 32, and its Height turned NaN (probe run 44783975649, x64 and Arm64).
  • New TheEditorHasFocusAsItOpensAndKeepsWhatIsTypedBeforeItLoads: focus and selection right after BeginEdit, and the caret kept after Loaded.
  • TheEditorCoversAWrappedRowAndWrapsItsTextAndWithWrapOffIsOneRowAgain: main's code failed it 4 of 5 runs on each runner (run 44783975649). With this change, EditingTests passed 10 of 10 runs on each runner, and the whole grid suite passed (run 44788178582).
  • Changed on purpose: TabCommitsAndEditsTheNextCell and AValueWithMixedLineBreaksOpenedAndLeftRaisesNothing kept the first edit's TextBox for the next edit. They now read grid.Editor for each edit.
  • CI: Windows (x64) and Windows (Arm64).

@datlechin
datlechin merged commit 8ac7164 into main Nov 20, 2026
14 checks passed
@datlechin
datlechin deleted the fix/windows-grid-wrap-off-editor branch November 21, 2026 04:35
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