Add decimal places support for TextInput on iOS#16119
Conversation
|
@ywongweb I tried to find reviewers for this pull request and wanted to ping them to take another look. However, based on the blame information for the files in this pull request I couldn't find any reviewers. This sometimes happens when the files in the pull request are new or don't exist on master anymore. Is this pull request still relevant? If yes could you please rebase? In case you know who has context on this code feel free to mention them in a comment (one person is fine). Thanks for reading and hope you will continue contributing to the project. |
@facebook-github-bot label Needs more information Attention: @shergin Generated by 🚫 dangerJS |
|
@ywongweb I tried to find reviewers for this pull request and wanted to ping them to take another look. However, based on the blame information for the files in this pull request I couldn't find any reviewers. This sometimes happens when the files in the pull request are new or don't exist on master anymore. Is this pull request still relevant? If yes could you please rebase? In case you know who has context on this code feel free to mention them in a comment (one person is fine). Thanks for reading and hope you will continue contributing to the project. |
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Maybe the issue has been fixed in a recent release, or perhaps it is not affecting a lot of people. If you think this issue should definitely remain open, please let us know why. Thank you for your contributions. |
Currently when we need to limit the number of decimal places in a
TextInput(a common use case is 2 decimals for currency) we have to do this via JS. This causes flickers if the user keeps entering after the maximum digits allowed is reached.This PR adds a
decimalPlacesprop to the TextInput component. Similar to themaxLengthprop, the logic to restrict the number of decimal places is done on the native side to eliminate any flickering. If set, it will also prevents the user from entering more than 1 decimal mark.Test Plan
Add a the following code to your project to limit the decimal places to 2.
If the user enters
0, it will have no effect on theTextInput.Android version will come later.
snack demo of the flickering
run this on an actual device
https://snack.expo.io/SyaYbJqsZ
Question:
Should I also add the decimal checking logic to
RCTTextView'stextInputShouldChangeTextInRangemethod?