From fb48484d2aee303e0226c060ae0e8f064d8cdf47 Mon Sep 17 00:00:00 2001 From: yflory Date: Thu, 26 Jan 2017 14:51:59 +0100 Subject: [PATCH] Fix the rename feature in drive not working with tables --- www/drive/file.css | 2 +- www/drive/file.less | 2 +- www/drive/main.js | 16 ++++++++++------ 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/www/drive/file.css b/www/drive/file.css index f28a9bfe2..0209c51e4 100644 --- a/www/drive/file.css +++ b/www/drive/file.css @@ -194,7 +194,7 @@ span.fa-folder-open { margin-left: 10px; float: right; } -#content li:not(.header) * { +#content li:not(.header) *:not(input) { pointer-events: none; } #content li:not(.header):hover .name { diff --git a/www/drive/file.less b/www/drive/file.less index 30a5b6a8f..c7aae36a9 100644 --- a/www/drive/file.less +++ b/www/drive/file.less @@ -235,7 +235,7 @@ span { } li { &:not(.header) { - * { + *:not(input) { pointer-events: none; } &:hover { diff --git a/www/drive/main.js b/www/drive/main.js index addfaaf29..d9d7d6c3a 100644 --- a/www/drive/main.js +++ b/www/drive/main.js @@ -235,7 +235,7 @@ define([ $iframe.find('.selected').removeClass("selected"); }; var removeInput = function () { - $iframe.find('li > span:hidden').attr('style', undefined); + $iframe.find('li > span:hidden').removeAttr('style'); $iframe.find('li > input').remove(); }; @@ -280,7 +280,8 @@ define([ } removeInput(); removeSelected(); - $element.hide(); + var $name = $element.find('.name'); + $name.hide(); var name = path[path.length - 1]; var $input = $('', { placeholder: name, @@ -295,7 +296,7 @@ define([ } }); //$element.parent().append($input); - $element.after($input); + $name.after($input); $input.focus(); $input.select(); // We don't want to open the file/folder when clicking on the input @@ -311,10 +312,12 @@ define([ }); // Make the parent element non-draggable when selecting text in the field // since it would remove the input - $input.on('mousedown', function () { + $input.on('mousedown', function (e) { + e.stopPropagation(); $input.parents('li').attr("draggable", false); }); - $input.on('mouseup', function () { + $input.on('mouseup', function (e) { + e.stopPropagation(); $input.parents('li').attr("draggable", true); }); }; @@ -322,6 +325,7 @@ define([ // Add the "selected" class to the "li" corresponding to the clicked element var onElementClick = function (e, $element, path) { // If "Ctrl" is pressed, do not remove the current selection + removeInput(); if (!e || !e.ctrlKey) { removeSelected(); } @@ -713,7 +717,7 @@ define([ var isNewFolder = module.newFolder && filesOp.comparePath(newPath, module.newFolder); if (isNewFolder) { appStatus.onReady(function () { - window.setTimeout(function () { displayRenameInput($name, newPath); }, 0); + window.setTimeout(function () { displayRenameInput($element, newPath); }, 0); }); delete module.newFolder; }