« get me outta code hell

Don't show menu if it doesn't contain any items - 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>2018-08-03 11:26:22 -0300
committerFlorrie <towerofnix@gmail.com>2018-08-03 11:26:22 -0300
commit69a6a07d11bdc86b47b4c547afeedcbf8e47907a (patch)
tree315d4695a39ada4c7d99768b1e8534876af578ee
parent2144ade7eb41b9a7e90e4deff59ac5f6dfd256cc (diff)
Don't show menu if it doesn't contain any items
-rw-r--r--ui.js5
1 files changed, 5 insertions, 0 deletions
diff --git a/ui.js b/ui.js
index 970adbf..99039cf 100644
--- a/ui.js
+++ b/ui.js
@@ -1432,6 +1432,11 @@ class ContextMenu extends FocusElement {
   }
 
   show({x = 0, y = 0, items}) {
+    items = items.filter(Boolean)
+    if (!items.length) {
+      return
+    }
+
     // This *should* work with a menu action which opens the menu again,
     // because the selected element will be restored before the menu is
     // opened the second time.