« get me outta code hell

Be a little careful in Form.updateSelectedElement - tui-lib - Pure Node.js library for making visual command-line programs (ala vim, ncdu)
about summary refs log tree commit diff
path: root/ui/form
diff options
context:
space:
mode:
authorFlorrie <towerofnix@gmail.com>2018-06-12 23:40:47 -0300
committerFlorrie <towerofnix@gmail.com>2018-06-12 23:40:47 -0300
commit5ca7837f83be3c3ea1081db150ece49875fa61a0 (patch)
treee339d94d9133a8a6f1d4a15f3a258af94d85cd55 /ui/form
parent774e1e094f0873be539242c5c80a4130200cb700 (diff)
Be a little careful in Form.updateSelectedElement
Diffstat (limited to 'ui/form')
-rw-r--r--ui/form/Form.js6
1 files changed, 5 insertions, 1 deletions
diff --git a/ui/form/Form.js b/ui/form/Form.js
index f1734ac..87763bb 100644
--- a/ui/form/Form.js
+++ b/ui/form/Form.js
@@ -71,7 +71,11 @@ module.exports = class Form extends FocusElement {
   }
 
   updateSelectedElement() {
-    if (this.root.select) {
+    if (this.root.select && this.inputs.length) {
+      if (this.curIndex > this.inputs.length - 1) {
+        this.curIndex = this.inputs.length - 1
+      }
+
       this.root.select(this.inputs[this.curIndex])
     }
   }