From f0b760b2c44656550e45abe522925c992bc81232 Mon Sep 17 00:00:00 2001 From: nightwing Date: Tue, 1 Sep 2015 00:08:08 +0400 Subject: [PATCH] fix the issue with menu items appearing in the wrong order --- plugins/c9.ide.ui/lib/menu/menu.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/plugins/c9.ide.ui/lib/menu/menu.js b/plugins/c9.ide.ui/lib/menu/menu.js index bfce4a33..d28173af 100644 --- a/plugins/c9.ide.ui/lib/menu/menu.js +++ b/plugins/c9.ide.ui/lib/menu/menu.js @@ -954,10 +954,17 @@ apf.menu = function(struct, tagName){ }; this.$initChildren = function() { - this.childNodes.forEach(function(amlNode) { + var ch = this.childNodes; + for (var i = 0; i < ch.length; i++) { + var amlNode = ch[i]; if (!amlNode.$amlLoaded) amlNode.dispatchEvent("DOMNodeInsertedIntoDocument"); - }); + // sometimes DOMNodeInsertedIntoDocument event handler puts $ext at the end of the popup + if (amlNode.previousSibling && amlNode.previousSibling.$ext && amlNode.$ext) + if (amlNode.$ext.previousSibling != amlNode.previousSibling.$ext) + if (amlNode.$ext.parentNode == amlNode.previousSibling.$ext.parentNode) + amlNode.$ext.parentNode.insertBefore(amlNode.$ext, amlNode.previousSibling.$ext.nextSibling); + } }; var insertBefore = this.insertBefore; this.insertBefore = function(node, beforeNode) {