Skip to content

Commit acc30fb

Browse files
committed
fix(VNumberInput): keep cursor position when typing decimal values
1 parent 2472ce9 commit acc30fb

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

packages/vuetify/src/components/VNumberInput/VNumberInput.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,9 @@ export const VNumberInput = genericComponent<VNumberInputSlots>()({
247247
if (potentialNewInputVal.split(decimalSeparator.value)[1]?.length > props.precision) {
248248
e.preventDefault()
249249
inputElement!.value = potentialNewNumber
250+
251+
const cursorPosition = (selectionStart ?? 0) + e.data.length
252+
inputElement!.setSelectionRange(cursorPosition, cursorPosition)
250253
}
251254
// Ignore decimal separator when precision = 0
252255
if (props.precision === 0 && potentialNewInputVal.includes(decimalSeparator.value)) {

0 commit comments

Comments
 (0)