« get me outta code hell

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:
Diffstat (limited to 'ui.js')
-rw-r--r--ui.js15
1 files changed, 10 insertions, 5 deletions
diff --git a/ui.js b/ui.js
index ae3cf32..85cefcd 100644
--- a/ui.js
+++ b/ui.js
@@ -737,7 +737,7 @@ class AppElement extends FocusElement {
     // Sets up event listeners that are common to ordinary grouplike listings
     // (made by newGrouplikeListing) as well as the queue grouplike listing.
 
-    grouplikeListing.pathElement.on('select', item => this.reveal(item))
+    grouplikeListing.pathElement.on('select', (item, child) => this.reveal(item, child))
     grouplikeListing.on('menu', (item, el) => this.showMenuForItemElement(el, grouplikeListing))
     /*
     grouplikeListing.on('select', item => this.editNotesFile(item, false))
@@ -758,7 +758,7 @@ class AppElement extends FocusElement {
     return menu
   }
 
-  reveal(item) {
+  reveal(item, child) {
     if (!this.tabberPane.visible) {
       return
     }
@@ -769,6 +769,9 @@ class AppElement extends FocusElement {
     const parent = item[parentSymbol]
     if (isGroup(item)) {
       tabberListing.loadGrouplike(item)
+      if (child) {
+        tabberListing.selectAndShow(child)
+      }
     } else if (parent) {
       if (tabberListing.grouplike !== parent) {
         tabberListing.loadGrouplike(parent)
@@ -3080,10 +3083,12 @@ class PathElement extends ListScrollForm {
     const itemPath = getItemPath(item)
     const parentPath = itemPath.slice(0, -1)
 
-    for (const pathItem of parentPath) {
-      const isFirst = pathItem === parentPath[0]
+    for (let i = 0; i < parentPath.length; i++) {
+      const pathItem = parentPath[i]
+      const nextItem = itemPath[i + 1]
+      const isFirst = (i === 0)
       const element = new PathItemElement(pathItem, isFirst)
-      element.on('select', () => this.emit('select', pathItem))
+      element.on('select', () => this.emit('select', pathItem, nextItem))
       element.fixLayout()
       this.addInput(element)
     }