This commit is contained in:
Rainer Simon 2020-09-24 16:59:13 +02:00
parent 6507ef4b73
commit 6b5a572b64
2 changed files with 7 additions and 7 deletions

View File

@ -43,7 +43,7 @@ const Autocomplete = props => {
props.onSubmit(inputValue);
}
const onKeyDown = evt => {
const onKeyUp = evt => {
const { value } = evt.target;
if (evt.which == 13 && highlightedIndex == -1) {
@ -52,6 +52,8 @@ const Autocomplete = props => {
setInputItems(props.vocabulary); // Show all options on key down
} else if (evt.which == 27) {
props.onCancel && props.onCancel();
} else {
props.onChange && props.onChange(value);
}
}
@ -59,11 +61,9 @@ const Autocomplete = props => {
<div ref={element} className="r6o-autocomplete">
<div {...getComboboxProps()}>
<input
{...getInputProps({ onKeyDown })}
onChange={evt => props.onChange && props.onChange(evt)}
{...getInputProps({ onKeyUp })}
placeholder={props.placeholder}
defaultValue={props.initialValue}
/>
defaultValue={props.initialValue} />
</div>
<ul {...getMenuProps()}>
{isOpen && inputItems.map((item, index) => (

View File

@ -37,9 +37,9 @@ const TagWidget = props => {
props.onRemoveBody(tag);
}
const onDraftChange = evt => {
const onDraftChange = value => {
const prev = draftTag.value.trim();
const updated = evt.target.value.trim();
const updated = value.trim();
if (prev.length === 0 && updated.length > 0) {
props.onAppendBody({ ...draftTag, value: updated });