Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove double click to rename feature as its bad ux #1231

Merged
merged 2 commits into from
Dec 12, 2023
Merged
Changes from all commits
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
33 changes: 4 additions & 29 deletions src/project/FileTreeView.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,10 @@ define(function (require, exports, module) {
// Constants

// Time range from first click to second click to invoke renaming.
var CLICK_RENAME_MINIMUM = 500,
RIGHT_MOUSE_BUTTON = 2,
const RIGHT_MOUSE_BUTTON = 2,
LEFT_MOUSE_BUTTON = 0;

var INDENTATION_WIDTH = 10;
const INDENTATION_WIDTH = 10;

/**
* @private
Expand Down Expand Up @@ -497,9 +496,7 @@ define(function (require, exports, module) {
* Ensures that we always have a state object.
*/
getInitialState: function () {
return {
clickTimer: null
};
return {};
},

/**
Expand Down Expand Up @@ -527,25 +524,13 @@ define(function (require, exports, module) {
// project-files-container and then the file tree will be one self-contained
// functional unit.
ViewUtils.scrollElementIntoView($("#project-files-container"), $(Preact.findDOMNode(this)), true);
} else if (!isSelected && wasSelected && this.state.clickTimer !== null) {
this.clearTimer();
}
},

clearTimer: function () {
if (this.state.clickTimer !== null) {
window.clearTimeout(this.state.clickTimer);
this.setState({
clickTimer: null
});
}
},

startRename: function () {
if (!this.props.entry.get("rename")) {
this.props.actions.startRename(this.myPath());
}
this.clearTimer();
},

/**
Expand All @@ -563,14 +548,7 @@ define(function (require, exports, module) {
return;
}

if (this.props.entry.get("selected") && !e.ctrlKey) {
if (this.state.clickTimer === null && !this.props.entry.get("rename")) {
var timer = window.setTimeout(this.startRename, CLICK_RENAME_MINIMUM);
this.setState({
clickTimer: timer
});
}
} else {
if (!(this.props.entry.get("selected") && !e.ctrlKey)) {
var language = LanguageManager.getLanguageForPath(this.myPath()),
doNotOpen = false;
if (language && language.isBinary() && "image" !== language.getId() &&
Expand Down Expand Up @@ -614,9 +592,6 @@ define(function (require, exports, module) {
*/
handleDoubleClick: function () {
if (!this.props.entry.get("rename")) {
if (this.state.clickTimer !== null) {
this.clearTimer();
}
if (FileUtils.shouldOpenInExternalApplication(
FileUtils.getFileExtension(this.myPath()).toLowerCase()
)) {
Expand Down
Loading