« get me outta code hell

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
diff options
context:
space:
mode:
Diffstat (limited to 'ui')
-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])
     }
   }