Forward sats to user: text trimming and menu click-out UX improvements (#397)

Co-authored-by: rleed <rleed1@pm.me>
Co-authored-by: keyan <keyan.kousha+huumn@gmail.com>
This commit is contained in:
rleed 2023-08-19 19:30:41 -04:00 committed by GitHub
parent 0f8ff45488
commit 799ec987b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 3 deletions

View File

@ -218,7 +218,7 @@ function FormGroup ({ className, label, children }) {
}
function InputInner ({
prepend, append, hint, showValid, onChange, overrideValue,
prepend, append, hint, showValid, onChange, onBlur, overrideValue,
innerRef, noForm, clear, onKeyDown, debounce, ...props
}) {
const [field, meta, helpers] = noForm ? [{}, {}, {}] : useField(props)
@ -283,6 +283,10 @@ function InputInner ({
onChange(formik, e)
}
}}
onBlur={(e) => {
field.onBlur(e)
onBlur && onBlur(e)
}}
isInvalid={invalid}
isValid={showValid && meta.initialValue !== meta.value && meta.touched && !meta.error}
/>
@ -325,13 +329,15 @@ export function InputUserSuggest ({ label, groupClassName, ...props }) {
const INITIAL_SUGGESTIONS = { array: [], index: 0 }
const [suggestions, setSuggestions] = useState(INITIAL_SUGGESTIONS)
const [ovalue, setOValue] = useState()
return (
<FormGroup label={label} className={groupClassName}>
<InputInner
{...props}
autoComplete='off'
onChange={(_, e) => getSuggestions({ variables: { q: e.target.value } })}
onChange={(_, e) => {
setOValue(e.target.value)
getSuggestions({ variables: { q: e.target.value.replace(/^[@ ]+|[ ]+$/g, '') } })
}}
overrideValue={ovalue}
onKeyDown={(e) => {
switch (e.code) {