« get me outta code hell

mtui - Music Text User Interface - user-friendly command line music player
about summary refs log tree commit diff
diff options
context:
space:
mode:
-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()
     }