Open Nedgeva opened 5 years ago
It's default React behavior, details here: https://github.com/facebook/react/issues/955#issuecomment-160703606 . I don't think we should track cursor position manually until we have it as a requirement :)
Looks like the issue is relevant because such behavior does describe what a numeric stepper should actually do, not a numeric input. Moreover I would expect top/bottom arrows to also work incrementing/decrementing the digit at the current caret position. Reopening.
NS should support 2 editing modes: one is full-editing which is enabled for integers and for floats to left from the point .
. And other is overwrite with tracking of caret position which is enabled for floats to the right from the point .
.
Delete/Backspace should behave differently - erase digits (usual behavior) on the left and reset to 0 on the right (amount of zero symbols should be controlled by precision property).
NS should drop the formatter
property because it is out of scope of editing numbers and may lead to value inconsistencies, for example it may insert additional .
. Instead we should use some predefined config like the one from accounting.js
(except arbitrary templates).
/cc @mankdev @sutarmin
I'd also suggest to replace underlying input[type=text]
component with a custom control with full support for numeric keys as well as control keys. Caret should be simulated like it's done in DateInput/TimeInput
.
Not sure if it's outside of component's scope. However let's clear some things with NS. Consider following code to reproduce behaviour (a little bit modified
NumericStepper.page.tsx
example):when entering value into NS input it's always set carete to an end.
Seems like it's going to happen only if value has fixed amount of digits.
Is it bug or expected behaviour?