Commit aa88ab28 authored by Sam McNally's avatar Sam McNally Committed by Commit Bot

Cancel renames in the directory tree when an empty name is chosen.

https://crrev.com/510729 updated renames outside the directory tree;
update renames in the directory tree to match.

Also fix a "Redundant double negation" eslint spotted 40 lines away and
demanded be fixed.

Bug: 934683
Change-Id: I1a915fa4359e87f807ccd0cdc346f3f7b7fba664
Reviewed-on: https://chromium-review.googlesource.com/c/1488478
Commit-Queue: Sam McNally <sammc@chromium.org>
Reviewed-by: default avatarNoel Gordon <noel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#635846}
parent 3fc4b2f9
...@@ -91,7 +91,7 @@ DirectoryTreeNamingController.prototype.attachAndStart = function( ...@@ -91,7 +91,7 @@ DirectoryTreeNamingController.prototype.attachAndStart = function(
this.isRemovableRoot_ = isRemovableRoot; this.isRemovableRoot_ = isRemovableRoot;
this.volumeInfo_ = this.isRemovableRoot_ ? assert(volumeInfo) : null; this.volumeInfo_ = this.isRemovableRoot_ ? assert(volumeInfo) : null;
if (!!this.currentDirectoryItem_) { if (this.currentDirectoryItem_) {
return; return;
} }
...@@ -129,10 +129,8 @@ DirectoryTreeNamingController.prototype.commitRename_ = function() { ...@@ -129,10 +129,8 @@ DirectoryTreeNamingController.prototype.commitRename_ = function() {
var entry = this.currentDirectoryItem_.entry; var entry = this.currentDirectoryItem_.entry;
var newName = this.inputElement_.value; var newName = this.inputElement_.value;
// If new name is the same as current name or empty (only for removable // If new name is the same as current name or empty, do nothing.
// devices), do nothing. if (newName === this.currentDirectoryItem_.label || newName.length == 0) {
if (newName === this.currentDirectoryItem_.label ||
(newName.length == 0 && this.isRemovableRoot_)) {
this.detach_(); this.detach_();
return; return;
} }
......
...@@ -430,8 +430,18 @@ testcase.dirRenameWithoutChangingCurrent = async function() { ...@@ -430,8 +430,18 @@ testcase.dirRenameWithoutChangingCurrent = async function() {
/** /**
* Tests renaming a folder to an empty string. * Tests renaming a folder to an empty string.
*/ */
testcase.dirRenameToEmptyString = function() { testcase.dirRenameToEmptyString = async function() {
return renameDirectoryFromDirectoryTreeAndConfirmAlertDialog(''); const appId = await setupForDirectoryTreeContextMenuTest();
await remoteCall.navigateWithDirectoryTree(
appId, RootPath.DOWNLOADS_PATH + '/photos', 'My files/Downloads');
await renamePhotosDirectoryTo(appId, '', false);
// Wait for the input to be removed.
await remoteCall.waitForElementLost(appId, '.tree-row > input');
// No dialog should be shown.
await remoteCall.waitForElementLost(appId, '.cr-dialog-container.shown');
}; };
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment