« get me outta code hell

Fix issue when a group being exited is the first item in its parent - mtui - Music Text User Interface - user-friendly command line music player
about summary refs log tree commit diff
path: root/ui.js
diff options
context:
space:
mode:
authorFlorrie <towerofnix@gmail.com>2018-06-03 18:03:33 -0300
committerFlorrie <towerofnix@gmail.com>2018-06-03 18:03:33 -0300
commit94ce17c784b7a9caa16522de67bf8b364f01d370 (patch)
tree8d39542dd1e48ecbc20bdee58fc83bc42d320f2d /ui.js
parentf64bd0252741a749b1f3bc57d79b134ecf42afcb (diff)
Fix issue when a group being exited is the first item in its parent
Diffstat (limited to 'ui.js')
-rw-r--r--ui.js8
1 files changed, 7 insertions, 1 deletions
diff --git a/ui.js b/ui.js
index 73442d0..241bf99 100644
--- a/ui.js
+++ b/ui.js
@@ -378,7 +378,13 @@ class GrouplikeListingElement extends ListScrollForm {
     if (parent) {
       const oldGrouplike = this.grouplike
       this.loadGrouplike(parent)
-      this.curIndex = this.inputs.findIndex(inp => inp.item === oldGrouplike) || this.firstItemIndex
+
+      const index = this.inputs.findIndex(inp => inp.item === oldGrouplike)
+      if (typeof index === 'number') {
+        this.curIndex = index
+      } else {
+        this.curIndex = this.firstItemIndex
+      }
       this.updateSelectedElement()
       this.scrollSelectedElementIntoView()
     }