Skip to content

Commit d6e9556

Browse files
committed
add check for projectNameInput on project title click
1 parent 2255bf1 commit d6e9556

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

client/modules/IDE/components/Toolbar.jsx

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ class Toolbar extends React.Component {
1818
super(props);
1919
this.handleKeyPress = this.handleKeyPress.bind(this);
2020
this.handleProjectNameChange = this.handleProjectNameChange.bind(this);
21+
this.handleProjectNameClick = this.handleProjectNameClick.bind(this);
2122
this.handleProjectNameSave = this.handleProjectNameSave.bind(this);
2223

2324
this.state = {
@@ -36,6 +37,17 @@ class Toolbar extends React.Component {
3637
this.setState({ projectNameInputValue: event.target.value });
3738
}
3839

40+
handleProjectNameClick() {
41+
if (this.canEditProjectName) {
42+
this.props.showEditProjectName();
43+
setTimeout(() => {
44+
if (this.projectNameInput) {
45+
this.projectNameInput.focus();
46+
}
47+
}, 140);
48+
}
49+
}
50+
3951
handleProjectNameSave() {
4052
const newProjectName = this.state.projectNameInputValue.trim();
4153
if (newProjectName.length === 0) {
@@ -132,12 +144,7 @@ class Toolbar extends React.Component {
132144
<div className={nameContainerClass}>
133145
<button
134146
className="toolbar__project-name"
135-
onClick={() => {
136-
if (canEditProjectName) {
137-
this.props.showEditProjectName();
138-
setTimeout(() => this.projectNameInput.focus(), 140);
139-
}
140-
}}
147+
onClick={this.handleProjectNameClick}
141148
disabled={!canEditProjectName}
142149
aria-label={this.props.t('Toolbar.EditSketchARIA')}
143150
>

0 commit comments

Comments
 (0)