0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-25 14:02:40 +00:00

Update tag keydown handler to allow tags that match a certain pattern

#758
This commit is contained in:
Charlie Humphreys
2021-11-18 23:05:39 -06:00
parent 19c13342c4
commit e2fe77ade7

View File

@@ -202,14 +202,19 @@ const MetadataEditor = createClass({
},
handleTagInputKeyDown : function(event, index){
if(event.key === 'Enter') {
if(!!index) {
this.updateTag(event.target.value, index);
const tagContext = this.state.tagContext;
tagContext[index].editing = false;
this.setState({ tagContext, updateTag: '' });
const tagPattern = /^(?:(?:group|meta|system|type):)?[A-Za-z0-9][A-Za-z0-9 /.:\-]+$/;
if(!!event.target.value.match(tagPattern)) {
if(!!index) {
this.updateTag(event.target.value, index);
const tagContext = this.state.tagContext;
tagContext[index].editing = false;
this.setState({ tagContext, updateTag: '' });
} else {
this.addTag(event.target.value);
this.setState({ temporaryTag: '' });
}
} else {
this.addTag(event.target.value);
this.setState({ temporaryTag: '' });
console.log('does not match');
}
}
},