Skip to content

Commit

Permalink
Fixed quickkeys alt+arrows moving over "show more" tag
Browse files Browse the repository at this point in the history
  • Loading branch information
josdejong committed May 12, 2018
1 parent 92a431e commit 6a15c04
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
5 changes: 5 additions & 0 deletions src/css/jsoneditor.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
20 changes: 13 additions & 7 deletions src/js/Node.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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;
};
Expand All @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit 6a15c04

Please sign in to comment.