Skip to content

Commit

Permalink
browser: treeview: fix click selection
Browse files Browse the repository at this point in the history
Change-Id: I4a231f9d9d3a556e848522f59df28dd78c861b97
Signed-off-by: Henry Castro <[email protected]>
  • Loading branch information
hcvcastro committed Aug 2, 2024
1 parent f69ad6a commit cffb16d
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions browser/src/control/jsdialog/Widget.TreeView.js
Original file line number Diff line number Diff line change
Expand Up @@ -1072,29 +1072,36 @@ class ComplexTableControl extends TreeViewControl {
}

static onClick(e) {
let td = e.target;
if (!td || td.localName !== 'td')
let tr = ComplexTableControl.findRow(e.target);
if (!tr)
return;

let tr = td.parentElement;
if (!tr || tr.localName !== 'tr')
return;

let expand = td.firstChild;
let expand = tr.firstChild.firstChild;
if (expand && tr.hasAttribute('aria-expanded') &&
e.clientX < expand.getBoundingClientRect().left) {
ComplexTableControl.toggleExpand(tr);
return;
}

let selected = tr.getAttribute('aria-selected') === 'true';

if (ComplexTableControl.Selected)
ComplexTableControl.selectEntry(ComplexTableControl.Selected, false);

ComplexTableControl.Selected = ComplexTableControl.selectEntry(tr, !selected);
}

static findRow(elem) {
let tr = elem;
if (tr && tr.localName === 'tbody')
return null;

while (tr && tr.localName !== 'tr') {
tr = tr.parentElement;
}

return tr;
}

fillCells(entry, builder, tr) {
let td, span, text, img, icon, iconId, iconName, link, innerText;

Expand Down

0 comments on commit cffb16d

Please sign in to comment.