Skip to content
This repository was archived by the owner on Sep 6, 2021. It is now read-only.

Fixed: Issue 2509 Double-clicking in rename input acts like double-clicking file normally #2802

Merged
merged 2 commits into from
Feb 8, 2013
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion src/project/ProjectManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,16 @@ define(function (require, exports, module) {
_redraw(true, false);
}

/**
* Returns false when the event occured without any input present in the li closest to the event.target
*
* @param {event} event to check
* @return boolean true if an input field is present
*/
function isInRename(event) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this function will be more useful if it takes an element (event.target) instead of an event. Code would then be:

return ($(element).closest("li").find("input").length > 0);

return ($(event.target).closest("li").find("input").length === 0);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic got reversed. You want to check length > 0, right?

}

/**
* @private
* Given an input to jsTree's json_data.data setting, display the data in the file tree UI
Expand Down Expand Up @@ -534,7 +544,7 @@ define(function (require, exports, module) {
.unbind("dblclick.jstree")
.bind("dblclick.jstree", function (event) {
var entry = $(event.target).closest("li").data("entry");
if (entry && entry.isFile) {
if (entry && entry.isFile && !isInRename(event)) {
FileViewController.addToWorkingSetAndSelect(entry.fullPath);
}
});
Expand Down Expand Up @@ -1356,4 +1366,5 @@ define(function (require, exports, module) {
exports.renameItemInline = renameItemInline;
exports.forceFinishRename = forceFinishRename;
exports.showInTree = showInTree;
exports.isInRename = isInRename;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove export for now. If anyone needs it, they can add it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, since it's no longer being exported, it's private, so name shold be _isInRename().

});