From e2fe77ade70cb4d0d7b862bda74629846906bd66 Mon Sep 17 00:00:00 2001 From: Charlie Humphreys Date: Thu, 18 Nov 2021 23:05:39 -0600 Subject: [PATCH] Update tag keydown handler to allow tags that match a certain pattern #758 --- .../editor/metadataEditor/metadataEditor.jsx | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/client/homebrew/editor/metadataEditor/metadataEditor.jsx b/client/homebrew/editor/metadataEditor/metadataEditor.jsx index 4ca3c89f0..48092318a 100644 --- a/client/homebrew/editor/metadataEditor/metadataEditor.jsx +++ b/client/homebrew/editor/metadataEditor/metadataEditor.jsx @@ -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'); } } },