From 339fea0977a4b0c9050111467c0f22b7a68447e0 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Mon, 25 Nov 2019 09:56:25 -0500 Subject: [PATCH] GUI: Add new block to the top Creates new items at top of block, underneath the fieldset legend if present --- ext/afform/gui/ang/afGuiEditor.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ext/afform/gui/ang/afGuiEditor.js b/ext/afform/gui/ang/afGuiEditor.js index 2db100106c..7ad8e075ed 100644 --- a/ext/afform/gui/ang/afGuiEditor.js +++ b/ext/afform/gui/ang/afGuiEditor.js @@ -374,7 +374,9 @@ } else if (classes[0] === 'af-text' || classes[0] === 'af-button') { newBlock['#children'] = [{'#text': ts('Enter text')}]; } - $scope.node['#children'].push(newBlock); + // Add new block to the top, underneath the fieldset legend if present + var pos = $scope.node['#children'].length && $scope.node['#children'][0]['#tag'] === 'legend' ? 1 : 0; + $scope.node['#children'].splice(pos, 0, newBlock); }; this.removeBlock = function(node) { -- 2.25.1