« 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.js12
1 files changed, 12 insertions, 0 deletions
diff --git a/ui.js b/ui.js
index b1eb7c4..a3860e9 100644
--- a/ui.js
+++ b/ui.js
@@ -3071,7 +3071,19 @@ class ContextMenu extends FocusElement {
     }
 
     if (this.visible) {
+      const newlySelected = this.root.selectedElement
       this.close()
+
+      // Bad hack: if the menubar is the selected thing, directly select it
+      // (hence setting its previously selected element to whatever we just
+      // restored the selection to as the context menu).
+      const menubar = newlySelected.directAncestors.find(
+        el => el instanceof Menubar)
+      if (menubar) {
+        menubar.select()
+      } else {
+        this.selectedBefore.root.select(newlySelected)
+      }
     }
   }