From aff72f26af65be210ee30f4480a837ac7c8b25e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Ign=C3=A1cio=20Fontoura=20Solla?= Date: Fri, 20 Mar 2026 17:54:22 -0300 Subject: [PATCH] Improve FormInput --- src/components/FormInput.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/components/FormInput.tsx b/src/components/FormInput.tsx index 9fddef33..713fb531 100644 --- a/src/components/FormInput.tsx +++ b/src/components/FormInput.tsx @@ -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 = (e) => {