Skip to content

Commit f0a183b

Browse files
committed
Pressing 'enter' in treeview loses focus
it goes from the dialog to the document. This can be seen in the chapter/heading dialog in writer. Open the dialog, press twice to ensure the focus can be seen in the treeview, press return, the focus disappears and up/down no longer had an effect. Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com> Change-Id: Iede45ff2bdd3ebdd46776ba48ee3ca009e3023a0
1 parent 54157e3 commit f0a183b

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1012,6 +1012,11 @@ class TreeViewControl {
10121012
return;
10131013
}
10141014

1015+
// Remember if the focused element is inside this treeview,
1016+
// because clearing selections removes tabindex which drops
1017+
// focus to BODY for non-natively-focusable elements.
1018+
const hadFocus = this._container.contains(document.activeElement);
1019+
10151020
// Clear existing selections
10161021
this._container
10171022
.querySelectorAll('.ui-treeview-entry.selected')
@@ -1021,7 +1026,7 @@ class TreeViewControl {
10211026

10221027
// Select the target row
10231028
const checkbox = rowElement.querySelector('input') as HTMLInputElement;
1024-
this.selectEntry(rowElement, checkbox, shouldFocus);
1029+
this.selectEntry(rowElement, checkbox, shouldFocus || hadFocus);
10251030
}
10261031

10271032
unselectEntry(item: HTMLElement) {

0 commit comments

Comments
 (0)