From c2239451471dfba4d463e884b7ed69b6ffcf92d3 Mon Sep 17 00:00:00 2001 From: Ian Gulliver Date: Thu, 20 Jun 2019 23:22:56 +0000 Subject: [PATCH] Move focus into first node on group creation, don't remove last node in list --- architype.js | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/architype.js b/architype.js index eacb59e..47539c0 100644 --- a/architype.js +++ b/architype.js @@ -23,6 +23,14 @@ class List { this.container_ = container; } + getEntries() { + let ret = []; + for (let elem of this.container_.children) { + ret.push(elem.xArchObj); + } + return ret; + } + getSelected() { let iter = document.activeElement; while (iter) { @@ -366,10 +374,15 @@ class Node extends EditorEntryBase { } onInputBlur() { - if (this.input_.value.length == 0) { + if (this.input_.value.length == 0 && (this.elem_.previousElementSibling || + this.elem_.nextElementSibling)) { this.remove(); } } + + getValue() { + return this.input_.value; + } } class Group extends EditorEntryBase { @@ -404,6 +417,12 @@ class Group extends EditorEntryBase { e.stopPropagation(); e.preventDefault(); this.stopEdit(); + { + let nodes = this.nodes_.getEntries(); + if (nodes.length == 1 && nodes[0].getValue() == '') { + nodes[0].startEdit(); + } + } break; case 'ArrowUp':