« get me outta code hell

Reset selection index when clearing queue - mtui - Music Text User Interface - user-friendly command line music player
about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFlorrie <towerofnix@gmail.com>2019-06-08 15:58:22 -0300
committerFlorrie <towerofnix@gmail.com>2019-06-08 15:58:22 -0300
commit9bd6e057b392f60cf31ae258ec46ac50b052697d (patch)
treeb66caf53c19bd1560960528c41b088a95c9c4c1a
parent6356da52f2f62bc877140d25a0a4d39627c5de81 (diff)
Reset selection index when clearing queue
-rw-r--r--ui.js8
1 files changed, 7 insertions, 1 deletions
diff --git a/ui.js b/ui.js
index 7056506..6f78b16 100644
--- a/ui.js
+++ b/ui.js
@@ -719,7 +719,7 @@ class AppElement extends FocusElement {
     this.queueGrouplike.items = this.queueGrouplike.items
       .filter(item => item === this.playingTrack)
     this.queueListingElement.buildItems()
-    this.queueListingElement.pathElement.showItem(null)
+    this.queueListingElement.selectNone()
     this.updateQueueLengthLabel()
   }
 
@@ -1411,6 +1411,12 @@ class GrouplikeListingElement extends Form {
     if (this.root.select) this.hideJumpElement()
   }
 
+  selectNone() {
+    this.pathElement.showItem(null)
+    this.form.curIndex = 0
+    this.form.scrollItems = 0
+  }
+
   buildItems(resetIndex = false) {
     if (!this.grouplike) {
       throw new Error('Attempted to call buildItems before a grouplike was loaded')