Skip to content

Commit ed481b9

Browse files
committed
Don't allow Collection name to be empty
1 parent 811c88f commit ed481b9

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

client/modules/IDE/components/CollectionList/CollectionListRow.jsx

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class CollectionListRowBase extends React.Component {
2323
optionsOpen: false,
2424
isFocused: false,
2525
renameOpen: false,
26-
renameValue: props.collection.name,
26+
renameValue: '',
2727
};
2828
}
2929

@@ -88,6 +88,7 @@ class CollectionListRowBase extends React.Component {
8888
this.closeAll();
8989
this.setState({
9090
renameOpen: true,
91+
renameValue: this.props.collection.name,
9192
});
9293
}
9394

@@ -98,17 +99,23 @@ class CollectionListRowBase extends React.Component {
9899
}
99100

100101
handleRenameEnter = (e) => {
102+
const isValid = this.state.renameValue !== '';
103+
101104
if (e.key === 'Enter') {
102-
this.props.editCollection(this.props.collection.id, { name: this.state.renameValue });
105+
if (isValid) {
106+
this.props.editCollection(this.props.collection.id, { name: this.state.renameValue });
107+
}
108+
109+
// this.resetName();
103110
this.closeAll();
104111
}
105112
}
106113

107-
resetSketchName = () => {
108-
this.setState({
109-
renameValue: this.props.collection.name
110-
});
111-
}
114+
// resetName = () => {
115+
// this.setState({
116+
// renameValue: this.props.collection.name
117+
// });
118+
// }
112119

113120
renderActions = () => {
114121
const { optionsOpen } = this.state;
@@ -181,7 +188,7 @@ class CollectionListRowBase extends React.Component {
181188
value={renameValue}
182189
onChange={this.handleRenameChange}
183190
onKeyUp={this.handleRenameEnter}
184-
onBlur={this.resetSketchName}
191+
// onBlur={this.resetName}
185192
onClick={e => e.stopPropagation()}
186193
/>
187194
}

client/modules/User/components/Collection.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ class Collection extends React.Component {
204204
<div className="collection-metadata__column--left">
205205
<h2 className="collection-metadata__name">
206206
{
207-
this.isOwner() ? <EditableInput value={name} onChange={handleEditCollectionName} /> : name
207+
this.isOwner() ? <EditableInput value={name} onChange={handleEditCollectionName} validate={value => value !== ''} /> : name
208208
}
209209
</h2>
210210

0 commit comments

Comments
 (0)