Skip to content

Kräfte: the STATUS combo in a grid row loses keyboard focus when its popup closes, so Down moves the grid cursor #536

Closed

Description

@DeepDiver1975

The problem

In the Kräfte grid, the STATUS ComboBox in a row gives up keyboard focus as soon as its popup closes. After you choose a status, pressing Down moves the DataGrid's cell cursor to the next row instead of changing the status. A Lagebuchführer working from the keyboard has to click back into the combo for every change.

This is the half of #294 that its three PRs (#531, #532, #533) did not fix. It also turns out not to be caused by the rebuild. #294 blamed the Clear() + re-add on session.Changed, but the focus loss happens with no save and no Changed at all.

Confirmed in the real app

main at 74b2837, the desktop build on a private Xvfb display with real X11 popups (not headless), the fictional docs/samples/uebung.fwincident and the demo Stammdaten.

1. Pick a status, then press Down (row 2).

Row 2: status picked, then Down moves the grid cursor to row 3

2. Control without any save: open, Escape, Down (row 1).

  • Open row 1's STATUS combo and close it with Escape. Nothing changes, nothing is saved, and Changed does not fire.
  • Down still moves the cell cursor from row 1 to row 2.

Row 1: combo opened and closed with Escape, then Down moves the grid cursor to row 2

So the focus loss comes from the ComboBox living inside the DataGrid, not from rows being rebuilt.

Why #294's control test did not catch this: it used the add form's STATUS combo, which keeps focus, and concluded that the rebuild was to blame. But that combo differs from the grid's in two ways at once. It is never rebuilt, and it is not inside a DataGrid. Now that the grid is no longer rebuilt (#531), the in-grid combo still loses focus, so the DataGrid is the remaining difference.

Note for a repro: use a middle row. On the last row a grid-cursor Down has nowhere to go and looks like "nothing happened".

Where to look (unverified)

  • The likely cause is that the DataGrid takes focus back for its current cell when the combo's popup closes. Alternatively, DataGrid may handle KeyDown for Down before the ComboBox sees it. Either would match what we see.
  • Check how Avalonia 12's DataGrid treats focusable controls in a DataGridTemplateColumn cell template, using the avalonia-docs MCP. Things to check:
    • the cell's Focusable and IsTabStop;
    • whether the column should be in edit mode (CellEditingTemplate);
    • whether the grid's IsReadOnly="True" (ForcesView.axaml) changes focus handling.
  • The same pattern probably affects every other focusable control in a grid cell: the Kräfte Bemerkung TextBox, and the Funktionen Handynummer. Those are only bearable because of the LostFocus commit added for Kräfte: typing a Bemerkung saves the whole incident file on every keystroke #33.

Verify

  • An [AvaloniaFact] on the real ForcesView that opens and closes a row's STATUS combo, then sends Down. It should assert that the status changed, not that the grid's current row moved. Headless focus has been unreliable here, so treat the test as the backstop.
  • The real check is the manual probe: pick a status on a middle row, press Down, and the status should step to the next option.

🤖 Generated with Claude Code

Activity

  1. added a commit that references this issue on Oct 21, 2026
    058273e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions