From e08250c3cb72c1639e00edddd5e3828b8bbd8398 Mon Sep 17 00:00:00 2001 From: jos Date: Wed, 17 Oct 2018 15:26:05 +0200 Subject: [PATCH] Fixed duplicate and remove of the action menu of multiple selected nodes not working --- HISTORY.md | 2 ++ src/js/treemode.js | 10 +++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index 5f549ea..5b723a1 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -9,6 +9,8 @@ https://github.com/josdejong/jsoneditor bar is disabled. - Fixed #589: the path in the navigation bar is not updated when deleting a node. +- Fixed duplicate and remove of the action menu of multiple selected + nodes not working. ## 2018-10-08, version 5.24.7 diff --git a/src/js/treemode.js b/src/js/treemode.js index 5e19b12..cc3a996 100644 --- a/src/js/treemode.js +++ b/src/js/treemode.js @@ -502,7 +502,7 @@ treemode._onChange = function () { this._debouncedValidate(); if (this.treePath) { - const selectedNode = this.selection + var selectedNode = this.selection ? this.node.findNodeByInternalPath(this.selection.path) : this.multiselection ? this.multiselection.nodes[0] @@ -1645,7 +1645,7 @@ treemode._createTable = function () { */ treemode.showContextMenu = function (anchor, onClose) { var items = []; - var editor = this; + var selectedNodes = this.multiselection.nodes.slice(); // create duplicate button items.push({ @@ -1653,7 +1653,7 @@ treemode.showContextMenu = function (anchor, onClose) { title: translate('duplicateTitle'), className: 'jsoneditor-duplicate', click: function () { - Node.onDuplicate(editor.multiselection.nodes); + Node.onDuplicate(selectedNodes ); } }); @@ -1663,12 +1663,12 @@ treemode.showContextMenu = function (anchor, onClose) { title: translate('removeTitle'), className: 'jsoneditor-remove', click: function () { - Node.onRemove(editor.multiselection.nodes); + Node.onRemove(selectedNodes); } }); var menu = new ContextMenu(items, {close: onClose}); - menu.show(anchor, editor.frame); + menu.show(anchor, this.frame); }; /**