« get me outta code hell

don't show a divider as the first item in a menu - 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>2020-07-09 17:09:02 -0300
committerFlorrie <towerofnix@gmail.com>2020-07-09 17:10:52 -0300
commitca096c7a64b5098ac1548d0996e871f63934b7ae (patch)
tree328dcfd17ae26b62c444795f6ab1bb97bc44222c
parent06128c9d42060b7513fb5490982e7f42b0ee596b (diff)
don't show a divider as the first item in a menu
-rw-r--r--ui.js10
1 files changed, 8 insertions, 2 deletions
diff --git a/ui.js b/ui.js
index f333b7a..0499ff6 100644
--- a/ui.js
+++ b/ui.js
@@ -3836,12 +3836,16 @@ class ContextMenu extends FocusElement {
     let wantDivider = false
     const addDividerIfWanted = () => {
       if (wantDivider) {
-        const element = new HorizontalRule()
-        this.form.addInput(element)
+        if (!firstItem) {
+          const element = new HorizontalRule()
+          this.form.addInput(element)
+        }
         wantDivider = false
       }
     }
 
+    let firstItem = true
+
     const keyElementMap = {}
 
     for (const item of items.filter(Boolean)) {
@@ -3854,6 +3858,7 @@ class ContextMenu extends FocusElement {
         if (item.isDefault) {
           this.root.select(item.element)
         }
+        firstItem = false
       } else if (item.divider) {
         wantDivider = true
       } else {
@@ -3875,6 +3880,7 @@ class ContextMenu extends FocusElement {
         if (item.isDefault) {
           this.root.select(button)
         }
+        firstItem = false
       }
       if (item.key) {
         keyElementMap[item.key] = focusEl