-
Notifications
You must be signed in to change notification settings - Fork 73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Currency input formatter empty value error #87
Comments
can you provide some code snippet to reproduce this? |
Screen.Recording.2022-08-20.at.18.55.18.movI've just checked it, and it works just fine |
Oh, I found one way to reproduce it. Is when you specify a 0 mantissa length. Ok, thanks for the report. I'll fix this |
Fixed in 2.6.1. I also found 2 related bugs and fixed them as well |
Thanks for the fix but there is another bug related to mantissa length being 0: if your cursor is set on the trailing symbol you are not able to delete but are able to type. |
It's not a bug, it's planned this way |
but if i set mantissa to 1 then i am able to delete input value. It displaces cursor to value first, bypassing the trailing symbol but i am still able to delete after that. |
video_2022-08-22_11-10-21.mp4 |
@caseyryan I'm facing the issue that's mentioned in very first comment. I understand that you had fixed it, but I'm encountering it. When I set the mantis to 0, then pressing the clear button erases the first number as well. Also, when setting the mantis greater than 0, the cursor is at the end of the decimal zeros, and the user has to clear up to the decimal point to start entering a value. |
second.mp4first.mp4 |
Sorry, I don't understand what you mean here. Shouldn't it clear the first digit? Why?
This is the correct behavior of the textfield. Of course it can be improved but the question is where should the caret go in this case? Before the decimal separator or after it? I believe the better solution is to give every developer an option to keep track of the focus themselves and select the behavior they want. In your case it might be reasonable to develop some kind of a wrapper around the text input and when it gathers focus check what text is entered there, for example, if the text ends with Something like this (I wrote the code right here so there may be some typos or sth, but you can get the idea): TextInputField(
controller: _textEditingController,
focusNode: _focusNode,
onFocusChange: () {
if (_focusNode.hasFocus) {
_textEditingController.setSelectionToComfortNumber(
_focusNode,
);
}
}
), and here how you can extend TextEditingController extension TextEditinControllerExtension on TextEditingController {
Future setSelectionToComfortNumber([
FocusNode? focusNode,
int delayMillis = 100,
]) async {
await Future.delayed(Duration(milliseconds: delayMillis));
final indexOfPeriod = text.lastIndexOf('.');
if (indexOfPeriod > -1) {
selection = TextSelection.collapsed(
offset: indexOfPeriod,
);
}
focusNode?.requestFocus();
}
} |
Thanks, I'll try it |
when i erase my currency value it becomes 0 and then if i type new numbers to that input field it doesn't erase the zero and leaves it at the start of the text
The text was updated successfully, but these errors were encountered: