From 5356ee379ebfd5e1e5257a2b4b6732fafb930016 Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Thu, 6 Oct 2016 17:53:28 -0400 Subject: [PATCH] Fix for chrome escape key, also fixes unbind issue with file manager after escaping closes #122 closes #121 --- .../server/js/filemanager/actions.blade.php | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/resources/views/server/js/filemanager/actions.blade.php b/resources/views/server/js/filemanager/actions.blade.php index 314a6771..36ca2ef4 100644 --- a/resources/views/server/js/filemanager/actions.blade.php +++ b/resources/views/server/js/filemanager/actions.blade.php @@ -98,12 +98,12 @@ class ActionsClass { const inputLoader = nameBlock.find('.input-loader'); inputField.focus(); - inputField.on('blur keypress', e => { + inputField.on('blur keydown', e => { // Save Field if ( - (e.type === 'keypress' && e.which === 27) + (e.type === 'keydown' && e.which === 27) || e.type === 'blur' - || (e.type === 'keypress' && e.which === 13 && currentName === inputField.val()) + || (e.type === 'keydown' && e.which === 13 && currentName === inputField.val()) ) { if (!_.isEmpty(currentLink)) { nameBlock.html(currentLink); @@ -111,13 +111,11 @@ class ActionsClass { nameBlock.html(currentName); } inputField.remove(); - ContextMenu.run(); + ContextMenu.unbind().run(); return; } - if (e.type === 'keypress' && e.which !== 13) return; - - console.log('did not'); + if (e.type === 'keydown' && e.which !== 13) return; inputLoader.show(); const currentPath = decodeURIComponent(nameBlock.data('path')); @@ -138,7 +136,10 @@ class ActionsClass { }).done(data => { nameBlock.attr('data-name', inputField.val()); if (!_.isEmpty(currentLink)) { - const newLink = currentLink.attr('href').substr(0, currentLink.attr('href').lastIndexOf('/')) + '/' + inputField.val(); + let newLink = currentLink.attr('href'); + if (nameBlock.parent().data('type') !== 'folder') { + newLink = newLink.substr(0, newLink.lastIndexOf('/')) + '/' + inputField.val(); + } currentLink.attr('href', newLink); nameBlock.html( currentLink.html(inputField.val()) @@ -164,6 +165,7 @@ class ActionsClass { }).popover('show'); }).always(() => { inputLoader.remove(); + ContextMenu.unbind().run(); }); }); }