Skip to content

Commit eba80da

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 0a4d7cd commit eba80da

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
@@ -1015,6 +1015,11 @@ class TreeViewControl {
10151015
return;
10161016
}
10171017

1018+
// Remember if the focused element is inside this treeview,
1019+
// because clearing selections removes tabindex which drops
1020+
// focus to BODY for non-natively-focusable elements.
1021+
const hadFocus = this._container.contains(document.activeElement);
1022+
10181023
// Clear existing selections
10191024
this._container
10201025
.querySelectorAll('.ui-treeview-entry.selected')
@@ -1024,7 +1029,7 @@ class TreeViewControl {
10241029

10251030
// Select the target row
10261031
const checkbox = rowElement.querySelector('input') as HTMLInputElement;
1027-
this.selectEntry(rowElement, checkbox, shouldFocus);
1032+
this.selectEntry(rowElement, checkbox, shouldFocus || hadFocus);
10281033
}
10291034

10301035
unselectEntry(item: HTMLElement) {

0 commit comments

Comments
 (0)