diff --git a/docs/en_US/release_notes_4_12.rst b/docs/en_US/release_notes_4_12.rst index ebb3b3d3c..923eeee61 100644 --- a/docs/en_US/release_notes_4_12.rst +++ b/docs/en_US/release_notes_4_12.rst @@ -32,4 +32,5 @@ Bug fixes | `Issue #4508 `_ - Fix accessibility issue for Datetime cell in backgrid. | `Issue #4520 `_ - Ensure the query tool will work with older versions of psycopg2 than we officially support, albeit without updatable resultsets. | `Issue #4525 `_ - Ensure command tags are shown in the messages tab of the Query Tool. -| `Issue #4536 `_ - Fix load on demand in View/Edit data mode. \ No newline at end of file +| `Issue #4536 `_ - Fix load on demand in View/Edit data mode. +| `Issue #4552 `_ - Fix some errors thrown on the JS console when dragging text in the Query Tool. \ No newline at end of file diff --git a/web/pgadmin/static/js/tree/tree.js b/web/pgadmin/static/js/tree/tree.js index f0388f7e9..1149a66fa 100644 --- a/web/pgadmin/static/js/tree/tree.js +++ b/web/pgadmin/static/js/tree/tree.js @@ -134,11 +134,15 @@ export class Tree { let dropDetailsFunc = this.getDraggable(data._type); if(dropDetailsFunc != null) { + + /* addEventListener is used here because import jquery.drag.event + * overrides the dragstart event set using element.on('dragstart') + * This will avoid conflict. + */ item.find('.aciTreeItem') - .attr('draggable', true) - .on('dragstart', (e)=> { + .attr('draggable', true)[0] + .addEventListener('dragstart', (e)=> { let dropDetails = dropDetailsFunc(data, item); - let origEvent = e.originalEvent; if(typeof dropDetails == 'string') { dropDetails = { @@ -160,16 +164,16 @@ export class Tree { } } - origEvent.dataTransfer.setData('text', JSON.stringify(dropDetails)); + e.dataTransfer.setData('text', JSON.stringify(dropDetails)); /* Required by Firefox */ - if(origEvent.dataTransfer.dropEffect) { - origEvent.dataTransfer.dropEffect = 'move'; + if(e.dataTransfer.dropEffect) { + e.dataTransfer.dropEffect = 'move'; } /* setDragImage is not supported in IE. We leave it to * its default look and feel */ - if(origEvent.dataTransfer.setDragImage) { + if(e.dataTransfer.setDragImage) { let dragItem = $(`
${_.escape(dropDetails.text)} @@ -179,7 +183,7 @@ export class Tree { $('body .drag-tree-node').remove(); $('body').append(dragItem); - origEvent.dataTransfer.setDragImage(dragItem[0], 0, 0); + e.dataTransfer.setDragImage(dragItem[0], 0, 0); } }); } diff --git a/web/pgadmin/tools/sqleditor/static/js/sqleditor.js b/web/pgadmin/tools/sqleditor/static/js/sqleditor.js index 7f1e02412..4e1302d7b 100644 --- a/web/pgadmin/tools/sqleditor/static/js/sqleditor.js +++ b/web/pgadmin/tools/sqleditor/static/js/sqleditor.js @@ -367,19 +367,27 @@ define('tools.querytool', [ if(self.handler.is_query_tool) { self.query_tool_obj.setOption('dragDrop', true); self.query_tool_obj.on('drop', (editor, e) => { - /* Stop firefox from redirecting */ - if(e.preventDefault) { - e.preventDefault(); - } - if (e.stopPropagation) { - e.stopPropagation(); + var dropDetails = null; + try { + JSON.parse(e.dataTransfer.getData('text')); + + /* Stop firefox from redirecting */ + + if(e.preventDefault) { + e.preventDefault(); + } + if (e.stopPropagation) { + e.stopPropagation(); + } + } catch(error) { + /* if parsing fails, it must be the drag internal of codemirror text */ + return; } + var cursor = editor.coordsChar({ left: e.x, top: e.y, }); - var dropDetails = JSON.parse(e.dataTransfer.getData('text')); - e.codemirrorIgnore = true; editor.replaceRange(dropDetails.text, cursor); editor.focus(); editor.setSelection({