From 6a15c04053db7c535aab86e62c3b935e1f6b430a Mon Sep 17 00:00:00 2001 From: jos Date: Sat, 12 May 2018 16:14:19 +0200 Subject: [PATCH] Fixed quickkeys alt+arrows moving over "show more" tag --- src/css/jsoneditor.css | 5 +++++ src/js/Node.js | 20 +++++++++++++------- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/css/jsoneditor.css b/src/css/jsoneditor.css index 802a66d..f2cf646 100644 --- a/src/css/jsoneditor.css +++ b/src/css/jsoneditor.css @@ -193,6 +193,11 @@ div.jsoneditor-tree div.jsoneditor-show-more a { color: #808080; } +div.jsoneditor-tree div.jsoneditor-show-more a:hover, +div.jsoneditor-tree div.jsoneditor-show-more a:focus { + color: #ee422e; +} + div.jsoneditor { color: #1A1A1A; border: 1px solid #3883fa; diff --git a/src/js/Node.js b/src/js/Node.js index bbe220f..28357e8 100644 --- a/src/js/Node.js +++ b/src/js/Node.js @@ -1623,6 +1623,14 @@ Node.prototype.getDom = function() { return dom.tr; }; +/** + * Test whether a Node is rendered and visible + * @returns {boolean} + */ +Node.prototype.isVisible = function () { + return this.dom && this.dom.tr && this.dom.tr.parentNode || false +}; + /** * DragStart event, fired on mousedown on the dragarea at the left side of a Node * @param {Node[] | Node} nodes @@ -2510,7 +2518,7 @@ Node.prototype.onEvent = function (event) { // focus // when clicked in whitespace left or right from the field or value, set focus var domTree = dom.tree; - if (target == domTree.parentNode && type == 'click' && !event.hasMoved) { + if (domTree && target == domTree.parentNode && type == 'click' && !event.hasMoved) { var left = (event.offsetX != undefined) ? (event.offsetX < (this.getLevel() + 1) * 24) : (event.pageX < util.getAbsoluteLeft(dom.tdSeparator));// for FF @@ -2744,9 +2752,7 @@ Node.prototype.onKeyDown = function (event) { var prevDom = dom.previousSibling; if (prevDom) { prevNode = Node.getNodeFromTarget(prevDom); - if (prevNode && prevNode.parent && - (prevNode instanceof AppendNode) - && !prevNode.isVisible()) { + if (prevNode && prevNode.parent && !prevNode.isVisible()) { oldSelection = this.editor.getDomSelection(); oldBeforeNode = lastNode.nextSibling(); @@ -3179,7 +3185,7 @@ Node.prototype._previousNode = function () { prevDom = prevDom.previousSibling; prevNode = Node.getNodeFromTarget(prevDom); } - while (prevDom && (prevNode instanceof AppendNode && !prevNode.isVisible())); + while (prevDom && prevNode && !prevNode.isVisible()); } return prevNode; }; @@ -3199,7 +3205,7 @@ Node.prototype._nextNode = function () { nextDom = nextDom.nextSibling; nextNode = Node.getNodeFromTarget(nextDom); } - while (nextDom && (nextNode instanceof AppendNode && !nextNode.isVisible())); + while (nextDom && nextNode && !nextNode.isVisible()); } return nextNode; @@ -3232,7 +3238,7 @@ Node.prototype._lastNode = function () { if (dom && dom.parentNode) { var lastDom = dom.parentNode.lastChild; lastNode = Node.getNodeFromTarget(lastDom); - while (lastDom && (lastNode instanceof AppendNode && !lastNode.isVisible())) { + while (lastDom && lastNode && !lastNode.isVisible()) { lastDom = lastDom.previousSibling; lastNode = Node.getNodeFromTarget(lastDom); }