diff --git a/frontend/src/Metamaps/Create.js b/frontend/src/Metamaps/Create.js index 7c3c4ff3..177e951f 100644 --- a/frontend/src/Metamaps/Create.js +++ b/frontend/src/Metamaps/Create.js @@ -140,7 +140,13 @@ const Create = { }, newTopic: { init: function() { - $('#topic_name').keyup(function() { + $('#topic_name').keyup(function(e) { + const ESC = 27 + + if (e.keyCode === ESC) { + Create.newTopic.hide() + } // if + Create.newTopic.name = $(this).val() }) @@ -301,13 +307,11 @@ const Create = { $('#synapse_desc').keyup(function(e) { const ESC = 27 - const BACKSPACE = 8 - const DELETE = 46 - if (e.keyCode === BACKSPACE && $(this).val() === '' || - e.keyCode === DELETE && $(this).val() === '' || - e.keyCode === ESC) { + + if (e.keyCode === ESC) { Create.newSynapse.hide() } // if + Create.newSynapse.description = $(this).val() }) @@ -317,6 +321,14 @@ const Create = { } }) + $('#synapse_desc').keydown(function(e) { + const TAB = 9 + if (Create.newSynapse.beingCreated && e.keyCode === TAB) { + e.preventDefault() + Synapse.createSynapseLocally() + } + }) + $('#synapse_desc').bind('typeahead:select', function(event, datum, dataset) { if (datum.id) { // if they clicked on an existing synapse get it Synapse.getSynapseFromAutocomplete(datum.id) diff --git a/frontend/src/Metamaps/JIT.js b/frontend/src/Metamaps/JIT.js index 3520b946..903cc11d 100644 --- a/frontend/src/Metamaps/JIT.js +++ b/frontend/src/Metamaps/JIT.js @@ -420,6 +420,8 @@ const JIT = { $('.rightclickmenu').remove() if (Mouse.boxStartCoordinates) { + Create.newSynapse.hide() + Create.newTopic.hide() Visualize.mGraph.busy = false Mouse.boxEndCoordinates = eventInfo.getPos() JIT.selectWithBox(e) @@ -434,7 +436,9 @@ const JIT = { } else if (node && !node.nodeFrom) { JIT.selectNodeOnRightClickHandler(node, e) } else { - // console.log('right clicked on open space') + // right click open space + Create.newSynapse.hide() + Create.newTopic.hide() } } },