Always execute first TreeView node click

Makes clicking items more responsive. Stops waiting to detect second click and instead always execute the action of the first click no matter what.

Test: Manual
Fixes: 158604325
Change-Id: Ib98d8ed1acdc4ab18577bc2c01febb17009f53de
This commit is contained in:
Pablo Gamito
2020-06-10 10:11:52 +01:00
parent 43bbd072a7
commit c081577406

View File

@@ -167,22 +167,23 @@ export default {
select() {
this.$emit('item-selected', this.item);
},
clicked() {
if (!this.clickTimeout) {
this.clickTimeout = setTimeout(() => {
// Single click
clicked(e) {
if (this.itemsClickable) {
this.select();
}
// Collapse on double click if leaf node
if (!this.isLeaf) {
if (!this.clickTimeout) {
this.clickTimeout = setTimeout(() => {
// Single click (double click hasn't occured before timeout end)
this.clickTimeout = null;
}, 500);
} else {
// Double click
clearTimeout(this.clickTimeout);
this.clickTimeout = null;
if (this.itemsClickable) {
this.select();
}
}, 200);
} else {
// Double click
clearTimeout(this.clickTimeout);
this.clickTimeout = null;
if (!this.isLeaf) {
this.toggleTree();
}
}