diff --git a/architype.js b/architype.js index 65f3b74..be72cad 100644 --- a/architype.js +++ b/architype.js @@ -92,9 +92,6 @@ class Editor { return; } elem.focus(); - elem.scrollIntoView({ - block: 'center', - }); } startEdit() { @@ -237,6 +234,7 @@ class Node { this.elem_ = document.createElement('li'); this.elem_.innerText = 'Node: '; this.elem_.tabIndex = 0; + this.elem_.addEventListener('focus', () => { this.onElemFocus(); }); this.input_ = document.createElement('input'); this.input_.type = 'text'; @@ -264,10 +262,14 @@ class Node { onInputBlur() { if (this.input_.value.length == 0) { - // this.elem_.remove(); + this.elem_.remove(); } } + onElemFocus() { + this.elem_.scrollIntoView({block: 'center'}); + } + static addBefore(container, elem) { let node = new Node(); container.insertBefore(node.elem_, elem); @@ -286,6 +288,7 @@ class Group { this.elem_ = document.createElement('li'); this.elem_.innerText = 'Group: '; this.elem_.tabIndex = 0; + this.elem_.addEventListener('focus', () => { this.onElemFocus(); }); this.input_ = document.createElement('input'); this.input_.type = 'text'; @@ -318,6 +321,10 @@ class Group { } } + onElemFocus() { + this.elem_.scrollIntoView({block: 'center'}); + } + static addBefore(container, elem) { let group = new Group(); container.insertBefore(group.elem_, elem);