« get me outta code hell

:disgust: Fix some selection issues - 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:
authorFlorrie <towerofnix@gmail.com>2019-01-10 00:34:17 -0400
committerFlorrie <towerofnix@gmail.com>2019-01-10 00:34:17 -0400
commit4ec41ab7af3166e20fc3300e39ec5327354787b4 (patch)
treedbc21d79cb3ac72d29d5b2ea91bebdbd0408ece6 /ui.js
parent9fcba1b3de3cae633ef3a779e4536e45fdc554da (diff)
:disgust: Fix some selection issues
* Menus opened from the queue wouldn't work before. Now they do.
  (Well, there's no code for them yet, but there was when I was
  testing.)
* Rebuilding the items of a listing while it's selected doesn't reset
  the selection (i.e. select AppElement -> Tabber -> left pane). So you
  can remove an item from the queue and have focus remain on the queue,
  at the index where the item you removed was.
Diffstat (limited to 'ui.js')
-rw-r--r--ui.js17
1 files changed, 10 insertions, 7 deletions
diff --git a/ui.js b/ui.js
index 3d71d24..4d6b637 100644
--- a/ui.js
+++ b/ui.js
@@ -966,9 +966,9 @@ class GrouplikeListingElement extends Form {
     const wasSelected = this.isSelected
     const form = this.form
 
-    while (form.inputs.length) {
-      form.removeInput(form.inputs[0], true, {fixLayout: false})
-    }
+    // Just outright scrap the old items - don't deal with any selection stuff
+    // (as a result of removeInput) yet.
+    form.inputs = []
 
     const parent = this.grouplike[parentSymbol]
     if (parent) {
@@ -2062,10 +2062,13 @@ class ContextMenu extends FocusElement {
   }
 
   clearItems() {
-    const inputs = this.form.inputs.slice()
-    for (const input of inputs) {
-      this.form.removeInput(input)
-    }
+    // Abhorrent hack - just erases children from memory. Leaves children
+    // thinking they've still got a parent, though. (Necessary to avoid crazy
+    // select() loops that probably explode the world... speaking of things
+    // to forget, that one time when I was figuring out menus in the queue.
+    // This makes them work.)
+    this.form.inputs = []
+    this.form.children = []
   }
 
   fixLayout() {