Skip to content

Commit 0a4d7cd

Browse files
committed
jsdialog: add id to treeview entries to preserve focus across updates
Treeview rows had no id attribute. When pressing Enter on a treeview entry, core triggers _updateWidgetImpl. That method saves document.activeElement.id, rebuilds the widget, then tries to restore focus by finding an element with that the old id. Since the button had no id the fallback of sending focus to the document body happens. Use the same fix and pattern as: commit 3f985cb Date: Tue Jun 17 13:23:38 2025 +0530 iconview: added support for keyboard navigation after click Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com> Change-Id: Ie37a93dc52d41668169a8c03bcae23c82ad9c710
1 parent 54157e3 commit 0a4d7cd

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

browser/src/control/jsdialog/Widget.TreeView.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,9 @@ class TreeViewControl {
367367
parent,
368368
);
369369
this._rows.set(String(entry.row), tr);
370+
371+
//id is needed to find the element to regain focus after widget is updated. see updateWidget in Control.JSDialogBuilder.js
372+
tr.id = data.id + '_' + entry.row;
370373
tr.setAttribute('level', String(level));
371374
(tr as any)._row = entry.row;
372375
const rowRole =

0 commit comments

Comments
 (0)