0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-26 05:12:39 +00:00

Add comma to "submit" buttons

Now comma (`,`) submits a tag, like `Enter`
This commit is contained in:
Gazook89
2024-09-18 23:54:12 -05:00
parent a54adc1e4b
commit 5b4a7c168f

View File

@@ -17,7 +17,8 @@ const TagInput = ({ unique = true, values = [], ...props }) => {
};
const handleInputKeyDown = (evt, value, clear = false) => {
if (evt.key === 'Enter') {
if (_.includes(['Enter', ','], evt.key)) {
evt.preventDefault();
submitTag(evt.target.value, value);
if(clear){ setTemporaryValue(''); }
};
@@ -88,7 +89,7 @@ const TagInput = ({ unique = true, values = [], ...props }) => {
placeholder={props.placeholder}
value={temporaryValue}
onChange={(e) => setTemporaryValue(e.target.value)}
onKeyDown={(evt) => handleInputKeyDown(evt, null, true)} />
onKeyDown={(evt) =>handleInputKeyDown(evt, null, true)} />
</div>
</div>
);