diff options
author | Florrie <towerofnix@gmail.com> | 2018-06-01 08:26:23 -0300 |
---|---|---|
committer | Florrie <towerofnix@gmail.com> | 2018-06-01 08:26:23 -0300 |
commit | eca1367aa1eb83b6ebd32e457903eb8df1d66c99 (patch) | |
tree | afa8ba15d7fcdd3a002a8a8f36a0ae8e0eef5313 | |
parent | 24466e09fabecb9cc47ed248bb976d32c70ab3e4 (diff) |
Select old group when going out of it
-rw-r--r-- | ui.js | 9 |
1 files changed, 8 insertions, 1 deletions
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 { |