From eca1367aa1eb83b6ebd32e457903eb8df1d66c99 Mon Sep 17 00:00:00 2001 From: Florrie Date: Fri, 1 Jun 2018 08:26:23 -0300 Subject: Select old group when going out of it --- ui.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/ui.js b/ui.js index 7a3a333..3d65d27 100644 --- a/ui.js +++ b/ui.js @@ -256,7 +256,10 @@ class GrouplikeListingElement extends ListScrollForm { if (parent) { const upButton = new Button('Up (to ' + (parent.name || 'unnamed group') + ')') upButton.on('pressed', () => { + const oldGrouplike = this.grouplike this.loadGrouplike(parent) + this.curIndex = this.inputs.findIndex(inp => inp.item === oldGrouplike) || this.firstItemIndex + this.updateSelectedElement() }) this.addInput(upButton) } @@ -275,7 +278,7 @@ class GrouplikeListingElement extends ListScrollForm { if (wasSelected) { if (resetIndex) { - this.curIndex = Math.min(this.inputs.length, 1) + this.curIndex = this.firstItemIndex this.scrollItems = 0 this.updateSelectedElement() } else { @@ -285,6 +288,10 @@ class GrouplikeListingElement extends ListScrollForm { this.fixLayout() } + + get firstItemIndex() { + return Math.min(this.inputs.length, 1) + } } class GrouplikeItemElement extends Button { -- cgit 1.3.0-6-gf8a5