Improve FormInput
This commit is contained in:
parent
c72cd6a86e
commit
aff72f26af
1 changed files with 3 additions and 2 deletions
|
|
@ -33,9 +33,10 @@ export const FormInput = <
|
|||
)
|
||||
|
||||
const handleUpdate = (e: EventTarget & HTMLInputElement, value: string) => {
|
||||
const selectionStart = e.selectionStart
|
||||
const selectiondistance = e.value.length - (e.selectionEnd ?? 0)
|
||||
e.value = value
|
||||
e.setSelectionRange(selectionStart, selectionStart)
|
||||
const caretPos = value.length - selectiondistance
|
||||
e.setSelectionRange(caretPos, caretPos)
|
||||
}
|
||||
|
||||
const handleInput: InputEventHandler<HTMLInputElement> = (e) => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue