-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Add regex to TextInput #51202
Add regex to TextInput #51202
Conversation
Hey! I see that you made changes to our Form component. Make sure to update the docs in FORMS.md accordingly. Cheers! |
@brunovjk Code-wise this is ready for review. Will add tests and screenshots later |
@s77rt I managed to reproduce a bug now that didn't exist before. Only on web browser, in native everything works fine.
Screen.Recording.2024-10-22.at.14.47.31.movCurious to know your test results :D Thank you very much. |
@brunovjk Thanks for catching that. It has been fixed and this is ready for review. |
Very good @s77rt, everything seems really good to me, just for one detail: If you type the maximum number of numbers, both in the integer and decimal places, and move the cursor to the point ( 51202_bug.mov |
@brunovjk That's expected because if you were allowed to remove the dot the entered number will exceed the maximum. |
Reviewer Checklist
Screenshots/VideosAndroid: Native51202_android_native.movAndroid: mWeb Chrome51202_android_web.moviOS: Native51202_ios_native.moviOS: mWeb Safari51202_ios_web.movMacOS: Chrome / Safari51202_web_browser.movMacOS: Desktop51202_web_desktop.mov |
Great, thanks for the explanation, it seems obvious now 😳 🤣 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Nice work on this! Looking forward to the next steps. 🚀
src/libs/MoneyRequestUtils.ts
Outdated
function amountRegex(decimals: number, amountMaxLength: number = CONST.IOU.AMOUNT_MAX_LENGTH): string { | ||
return decimals === 0 | ||
? `^\\d{0,${amountMaxLength}}$` // Don't allow decimal point if decimals === 0 | ||
: `^\\d{0,${amountMaxLength}}(\\.\\d{0,${decimals}})?$`; // Allow the decimal point and the desired number of digits after the point |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does work with internationalization where ,
is used instead of a .
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh great catch! I think I broke that 😅 On main we replace the commas with periods but with the regex prop you won't be even allowed to insert a comma. The problem is due to the fact that what the user is allowed to enter and what we consider a valid input are two different things (because we format the user input).
i believe same bug occurs with entering .45
.45
is not a valid input- but the user can still enter
.45
because we format it to0.45
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm going to bring this back to draft to see how we can handle this. We can have 2 regexes (one for user input validation and the other for formatted text validation) but I don't really like that option. Will look for better options
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just realized that the second problem won't occur because the modified regex already allows for .45
. To keep this simple I added the comma to the regex amount so we can insert it, we still replace it with a period.
Screen.Recording.2024-10-25.at.8.36.07.PM.mov
Excuse me @s77rt, I got confused, can I test again? Thanks. |
@brunovjk Yes please do. Mostly you just need to make sure that we can type a comma and that it gets replaced by a period (as in main). |
First it quickly appears pr.movHowever, I can't reproduce it consistently. Can you @s77rt? I wonder if it's something with my build. Otherwise, everything seems fine to me: Screenshots/VideosAndroid: Native51202_android_native.movAndroid: mWeb Chrome51202_android_web.moviOS: Native51202_ios_native.moviOS: mWeb Safari51202_ios_web.movMacOS: Chrome / Safari51202_web_chrome.movMacOS: Desktop51202_web_desktop.mov |
@brunovjk That's the expected results for now |
🧪🧪 Use the links below to test this adhoc build on Android, iOS, Desktop, and Web. Happy testing! 🧪🧪
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM and tests well
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
Performance Comparison Report 📊Significant Changes To Duration
Show details
Meaningless Changes To DurationShow entries
Show details
|
@Expensify/mobile-deployers 📣 Please look into this performance regression as it's a deploy blocker. |
Performance degradtion not caused by this PR. I saw other merged PRs failing with this already |
🚀 Deployed to staging by https://github.com/luacmartins in version: 9.0.56-0 🚀
|
🚀 Deployed to production by https://github.com/Julesssss in version: 9.0.56-9 🚀
|
Details
Fixed Issues
$ #47875
PROPOSAL: #47875 (comment)
Tests
45.67
Offline tests
Same as Tests
QA Steps
Same as Tests
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodSTYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)Design
label and/or tagged@Expensify/design
so the design team can review the changes.ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
MacOS: Desktop