« 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/form/Form.js
diff options
context:
space:
mode:
Diffstat (limited to 'ui/form/Form.js')
-rw-r--r--ui/form/Form.js12
1 files changed, 7 insertions, 5 deletions
diff --git a/ui/form/Form.js b/ui/form/Form.js
index 708de1f..ce064aa 100644
--- a/ui/form/Form.js
+++ b/ui/form/Form.js
@@ -80,15 +80,17 @@ module.exports = class Form extends FocusElement {
     this.updateSelectedElement()
   }
 
-  firstInput() {
+  firstInput(selectForm = true) {
     this.curIndex = 0
 
-    this.updateSelectedElement()
+    if (selectForm || (
+      this.root.isChildOrSelfSelected && this.root.isChildOrSelfSelected(this)
+    )) {
+      this.updateSelectedElement()
+    }
   }
 
   focused() {
-    if (this.root.select) {
-      this.root.select(this.inputs[this.curIndex])
-    }
+    this.updateSelectedElement()
   }
 }