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:
parent
0f8ff45488
commit
799ec987b4
@ -218,7 +218,7 @@ function FormGroup ({ className, label, children }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function InputInner ({
|
function InputInner ({
|
||||||
prepend, append, hint, showValid, onChange, overrideValue,
|
prepend, append, hint, showValid, onChange, onBlur, overrideValue,
|
||||||
innerRef, noForm, clear, onKeyDown, debounce, ...props
|
innerRef, noForm, clear, onKeyDown, debounce, ...props
|
||||||
}) {
|
}) {
|
||||||
const [field, meta, helpers] = noForm ? [{}, {}, {}] : useField(props)
|
const [field, meta, helpers] = noForm ? [{}, {}, {}] : useField(props)
|
||||||
@ -283,6 +283,10 @@ function InputInner ({
|
|||||||
onChange(formik, e)
|
onChange(formik, e)
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
|
onBlur={(e) => {
|
||||||
|
field.onBlur(e)
|
||||||
|
onBlur && onBlur(e)
|
||||||
|
}}
|
||||||
isInvalid={invalid}
|
isInvalid={invalid}
|
||||||
isValid={showValid && meta.initialValue !== meta.value && meta.touched && !meta.error}
|
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 INITIAL_SUGGESTIONS = { array: [], index: 0 }
|
||||||
const [suggestions, setSuggestions] = useState(INITIAL_SUGGESTIONS)
|
const [suggestions, setSuggestions] = useState(INITIAL_SUGGESTIONS)
|
||||||
const [ovalue, setOValue] = useState()
|
const [ovalue, setOValue] = useState()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<FormGroup label={label} className={groupClassName}>
|
<FormGroup label={label} className={groupClassName}>
|
||||||
<InputInner
|
<InputInner
|
||||||
{...props}
|
{...props}
|
||||||
autoComplete='off'
|
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}
|
overrideValue={ovalue}
|
||||||
onKeyDown={(e) => {
|
onKeyDown={(e) => {
|
||||||
switch (e.code) {
|
switch (e.code) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user