diff --git a/app/src/frontend/building/data-components/autofill/autofillDropdown.tsx b/app/src/frontend/building/data-components/autofill/autofillDropdown.tsx index 6fadcd33..60f258e8 100644 --- a/app/src/frontend/building/data-components/autofill/autofillDropdown.tsx +++ b/app/src/frontend/building/data-components/autofill/autofillDropdown.tsx @@ -27,14 +27,14 @@ export const AutofillDropdown: React.FC = props => { useEffect(() => { const doAsync = async () => { - if (!props.editing || props.fieldValue === '') return setOptions(null); + if (!props.editing || (props.fieldValue === '' && options == null)) return setOptions(null); const url = `/api/autofill?field_name=${props.fieldName}&field_value=${props.fieldValue}`; - const { options } = await apiGet(url); + const { options: newOptions } = await apiGet(url); if (!props.editing) return; - setOptions(options); + setOptions(newOptions); }; doAsync(); @@ -47,6 +47,7 @@ export const AutofillDropdown: React.FC = props => { { options.map(option =>
/* prevent input blur */ e.preventDefault()} onClick={e => { props.onSelect(option.value); diff --git a/app/src/frontend/building/data-components/data-entry-input.tsx b/app/src/frontend/building/data-components/data-entry-input.tsx index 56a0a8e6..f6b47428 100644 --- a/app/src/frontend/building/data-components/data-entry-input.tsx +++ b/app/src/frontend/building/data-components/data-entry-input.tsx @@ -5,6 +5,7 @@ import { AutofillDropdown } from './autofill/autofillDropdown'; export interface TextDataEntryInputProps { slug: string; name?: string; + id?: string; onChange?: (key: string, val: any) => void; maxLength?: number; @@ -16,6 +17,8 @@ export interface TextDataEntryInputProps { export const DataEntryInput: React.FC = props => { const [isEditing, setEditing] = useState(false); + const nameAttr = props.name || props.slug; + const idAttr = props.id || props.slug; const handleChange = (value: string) => { console.log(value); @@ -27,17 +30,18 @@ export const DataEntryInput: React.FC setEditing(true)} - onBlur={e => setEditing(false)} - > + <> handleChange(e.target.value)} + onInput={e => setEditing(true)} + onFocus={e => setEditing(true)} + onBlur={e => setEditing(false)} /> { props.autofill && @@ -49,6 +53,6 @@ export const DataEntryInput: React.FC } -
+ ); }; diff --git a/app/src/frontend/building/data-components/multi-data-entry.tsx b/app/src/frontend/building/data-components/multi-data-entry.tsx index 9932b803..62eb1a1b 100644 --- a/app/src/frontend/building/data-components/multi-data-entry.tsx +++ b/app/src/frontend/building/data-components/multi-data-entry.tsx @@ -69,16 +69,18 @@ class MultiDataEntry extends Component tooltip={props.tooltip} disabled={props.disabled || props.value == undefined || props.value.length === 0} /> -
    +
      { values.length === 0 &&
      No entries
      } { values.map((val, i) => ( -
    • +
    • this.edit(i, val)} @@ -105,6 +107,8 @@ class MultiDataEntry extends Component
      this.setNewValue(val)}