From fdf181b8e0cad6b51b885dee3bd4209514870a36 Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Wed, 22 Apr 2015 16:57:27 -0700 Subject: [PATCH] return tagless values for list items. --- lib/widget.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/widget.js b/lib/widget.js index a0d0b51..d14ec2c 100644 --- a/lib/widget.js +++ b/lib/widget.js @@ -5381,7 +5381,7 @@ List.prototype.fuzzyFind = function(search, back) { } if (!back) { - for (var i = start; i < this.ritems.length; i++){ + for (var i = start; i < this.items.length; i++){ if (test(this.items[i].getText())) return i; } for (var i = 0; i < start; i++){ @@ -5403,7 +5403,14 @@ List.prototype.getItemIndex = function(child) { if (typeof child === 'number') { return child; } else if (typeof child === 'string') { - return this.ritems.indexOf(child); + var i = this.ritems.indexOf(child); + if (~i) return i; + for (i = 0; i < this.items.length; i++) { + if (this.items[i].getText() === child) { + return i; + } + } + return -1; } else { return this.items.indexOf(child); } @@ -5489,7 +5496,7 @@ List.prototype.select = function(index) { this._listInitialized = true; this.selected = index; - this.value = this.ritems[this.selected]; + this.value = this.items[this.selected].getText(); if (!this.parent) return; this.scrollTo(this.selected); }; @@ -5537,7 +5544,7 @@ List.prototype.pick = function(label, callback) { self.hide(); self.screen.render(); if (!el) return callback(); - return callback(null, self.ritems[selected]); + return callback(null, self.items[selected].getText()); }); };