Skip to content

Commit

Permalink
Fixed josdejong#598: Search field can't be focused in object view
Browse files Browse the repository at this point in the history
  • Loading branch information
josdejong committed Nov 13, 2018
1 parent 3065dad commit 2cd9cc1
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
7 changes: 7 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
https://github.com/josdejong/jsoneditor


## not yet released, version 5.26.1

- Fixed `.update()` throwing an exception when replacing a JSON object
with `null`. Thanks @DullReferenceException.
- Fixed #598: Search field can't be focused in object view.


## 2018-11-12, version 5.26.0

- Implemented option `mainMenuBar` to enable/disable the main menu bar.
Expand Down
3 changes: 2 additions & 1 deletion src/js/treemode.js
Original file line number Diff line number Diff line change
Expand Up @@ -1181,7 +1181,8 @@ treemode._onEvent = function (event) {
}
}
else {
if (event.type === 'mousedown') {
// filter mouse events in the contents part of the editor (not the main menu)
if (event.type === 'mousedown' && util.hasParentNode(event.target, editor.content)) {
this.deselect();

if (node && event.target === node.dom.drag) {
Expand Down
19 changes: 19 additions & 0 deletions src/js/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,25 @@ exports.getInnerText = function getInnerText(element, buffer) {
return '';
};

/**
* Test whether an element has the provided parent node somewhere up the node tree.
* @param {Element} elem
* @param {Element} parent
* @return {boolean}
*/
exports.hasParentNode = function (elem, parent) {
var e = elem ? elem.parentNode : undefined;

while (e) {
if (e === parent) {
return true;
}
e = e.parentNode;
}

return false;
}

/**
* Returns the version of Internet Explorer or a -1
* (indicating the use of another browser).
Expand Down

0 comments on commit 2cd9cc1

Please sign in to comment.