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:
@@ -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>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user