0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-08 14:02:41 +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,6 +202,8 @@ const MetadataEditor = createClass({
}, },
handleTagInputKeyDown : function(event, index){ handleTagInputKeyDown : function(event, index){
if(event.key === 'Enter') { if(event.key === 'Enter') {
const tagPattern = /^(?:(?:group|meta|system|type):)?[A-Za-z0-9][A-Za-z0-9 /.:\-]+$/;
if(!!event.target.value.match(tagPattern)) {
if(!!index) { if(!!index) {
this.updateTag(event.target.value, index); this.updateTag(event.target.value, index);
const tagContext = this.state.tagContext; const tagContext = this.state.tagContext;
@@ -211,6 +213,9 @@ const MetadataEditor = createClass({
this.addTag(event.target.value); this.addTag(event.target.value);
this.setState({ temporaryTag: '' }); this.setState({ temporaryTag: '' });
} }
} else {
console.log('does not match');
}
} }
}, },