-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
[$250] Tax - After a digit, entering dot moves the first digit while adding tax rate #56951
Comments
Triggered auto assignment to @twisterdotcom ( |
Job added to Upwork: https://www.upwork.com/jobs/~021892375042404364604 |
Triggered auto assignment to Contributor-plus team member for initial proposal review - @eh2077 ( |
🚨 Edited by proposal-police: This proposal was edited at 2025-02-20 07:20:09 UTC. ProposalPlease re-state the problem that we are trying to solve in this issue.Tax - After a digit, entering dot moves the first digit while adding tax rate What is the root cause of that problem?The regex required a digit after In
What changes do you think we should make in order to solve the problem?In Update this line in const regexString =
decimals === 0
? `^${shouldAllowNegative ? '-?' : ''}\\d{1,${amountMaxLength}}$`
: `^${shouldAllowNegative ? '-?' : ''}\\d{1,${amountMaxLength}}(\\.\\d{0,${decimals}})?$`; to this: const regexString =
decimals === 0
? `^${shouldAllowNegative ? '-?' : ''}\\d{1,${amountMaxLength}}$`
: `^${shouldAllowNegative ? '-?' : ''}\\d{1,${amountMaxLength}}(\\.?\\d{0,${decimals}})?$`; What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?
What alternative solutions did you explore? (Optional) |
|
@D-01576 Thanks for your proposal. But your root cause analysis is not clear to me. Can you elaborate please? |
/src/pages/workspace/taxes/ValuePage.tsx at line 88 InputComponent={AmountForm} /src/components/AmountForm.tsx at line 137 if (!MoneyRequestUtils.validateAmount(newAmountWithoutSpaces, decimals, amountMaxLength)) {
setSelection((prevSelection) => ({...prevSelection}));
return;
} returning the same value for setNewAmount /src/libs/MoneyRequestUtils.ts at function validateAmount const regexString =
decimals === 0
? `^${shouldAllowNegative ? '-?' : ''}\d{1,${amountMaxLength}}$`
: `^${shouldAllowNegative ? '-?' : ''}\d{1,${amountMaxLength}}(\.\d{0,${decimals}})?$`; not validating the string const regexString =
decimals === 0
? `^${shouldAllowNegative ? '-?' : ''}\d{1,${amountMaxLength}}$`
: `^${shouldAllowNegative ? '-?' : ''}\d{1,${amountMaxLength}}(\.?\d{0,${decimals}})?$`; then it might validate |
Shouldn't the original regex match |
Let me find any acceptable solution
…On Thu, Feb 20, 2025, 7:58 PM Eric Han ***@***.***> wrote:
Shouldn't the original regex match 3.0? Sorry, I can't follow you.
—
Reply to this email directly, view it on GitHub
<#56951 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/BAVOODYPSOE2IM27X3LMJNT2QXURVAVCNFSM6AAAAABXJTNSJKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDMNZRG42TAOBUGU>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
[image: eh2077]*eh2077* left a comment (Expensify/App#56951)
<#56951 (comment)>
Shouldn't the original regex match 3.0? Sorry, I can't follow you.
—
Reply to this email directly, view it on GitHub
<#56951 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/BAVOODYPSOE2IM27X3LMJNT2QXURVAVCNFSM6AAAAABXJTNSJKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDMNZRG42TAOBUGU>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
🚨 Edited by proposal-police: This proposal was edited at 2025-03-03 15:42:08 UTC. ProposalPlease re-state the problem that we are trying to solve in this issue.After a digit, entering dot moves the first digit while adding tax rate What is the root cause of that problem?We are using a text input with currency symbol to enter the rate value. App/src/components/AmountForm.tsx Line 280 in cc232a0
The width of the input, including the currency symbol, depends on the value of the text input, meaning the width is determined by the value. When we input a dot (".") and the width of the text input is not sufficient, the dot pushes the current value to the left because the width of the text input is not updated immediately upon input; it only updates after the input is complete. As shown in the video below, we can see that the onLayout update occurs only after the value is input (late a bit). Screen.Recording.2025-02-24.at.12.55.17.movWhat changes do you think we should make in order to solve the problem?We should create space for amountTextInput to fix this issue. For example, we can set a minimum width or width to ensure the text input has enough space before entering a new amount. Steps to implement this solution for the steps below:
const isLTRWithoutButtonOnNonWeb = isCurrencySymbolLTR && !currencySymbolButton && getPlatform() !== CONST.PLATFORM.WEB;
App/src/components/TextInputWithCurrencySymbol/BaseTextInputWithCurrencySymbol.tsx Line 64 in 5e98efc
update to: style={[styles.pr1, style, isLTRWithoutButtonOnNonWeb ? {width: '100%', textAlign: 'center'} : undefined]}
App/src/components/TextInputWithCurrencySymbol/BaseTextInputWithCurrencySymbol.tsx Line 69 in 5e98efc add: if (isLTRWithoutButtonOnNonWeb) {
return (
<>
<>
{amountTextInput}
<View style={{opacity: 0}}>{extraSymbol}</View>
</>
<View
style={{
position: 'absolute',
left: 0,
right: 0,
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'center',
width: '100%',
}}
>
<Text style={[style, {opacity: 0}]}>{formattedAmount || 0}</Text>
{extraSymbol}
</View>
</>
);
} Screen.Recording.2025-02-26.at.21.54.57.mp4What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?None What alternative solutions did you explore? (Optional)Reminder: Please use plain English, be brief and avoid jargon. Feel free to use images, charts or pseudo-code if necessary. Do not post large multi-line diffs or write walls of text. Do not create PRs unless you have been hired for this job. We update App/src/components/TextInputWithCurrencySymbol/BaseTextInputWithCurrencySymbol.tsx Line 54 in 5e98efc
add: <AmountTextInput
...
autoGrowExtraSpace={variables.w80} // add this
{...rest}
/> Note: |
@huult Thank you for your proposal!
Can you elaborate? It'll be easier to follow if you can explain the root cause according to the source code. |
@eh2077 Sure. I will update the RCA and mention the code next Monday. |
Proposal updated
@eh2077, could you review this again? Thank you. |
@huult Thanks for the update. I think your RCA is correct but I have concerns about your solution. Can we fix it with style and avoid adding states? |
@eh2077 I will try this |
Can we change the input's min-width from the style? |
Proposal updated
@eh2077 Could you check my alternative solutions? App/src/components/AmountForm.tsx Line 278 in cc232a0
In my opinion, we should use my main solution because it works well and is easier to approach than the style-based solution. Because: We need to set min-width and text-align: right to fix the issue. The value of min-width cannot be hardcoded because it is dynamic, and setting it too large would cause the amount and percentage to shift too far to the right. ![]() If we calculate the min-width value dynamically, we don't have an exact value to use. minWidth: ${formattedAmount.length * 25 + 10}, where 25 and 10 are buffer values. The value 25 represents the width of the amount, and 10 is the buffer for the dot. Additionally, the function will become more complex when handling more cases, such as ensuring the buffer is added only once, similar to the solution that checks whether a dot has been added or not. With this approach, it is not 100% accurate because the text may be slightly too far to the right due to calculating the exact width of the amount. So, let me know what you think? |
Screen.Recording.2025-02-25.at.10.38.35.PM.mov@huult I found that, after a digit, entering |
Still looking for better proposals! |
@eh2077 How about this position? if (isLTRWithoutButtonOnNonWeb) {
return (
<>
{amountTextInput}
<View
style={{
position: 'absolute',
left: 0,
right: 0,
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'center',
width: '100%',
}}
>
<Text style={[style, {opacity: 0, paddingLeft: 35}]}>{formattedAmount || 0}</Text>
{extraSymbol}
</View>
</>
);
} |
@huult This still looks like a hack to me. <Text style={[style, {opacity: 0, paddingLeft: 35}]}>{formattedAmount || 0}</Text> |
@eh2077 I have a new solution using |
Proposal updated
@eh2077 could you check it again? thanks |
📣 It's been a week! Do we have any satisfactory proposals yet? Do we need to adjust the bounty for this issue? 💸 |
@eh2077 This only jumps digits the first time, and the issue with input dots is resolved. |
@eh2077 Whoops! This issue is 2 days overdue. Let's get this updated quick! |
@eh2077 @twisterdotcom My main solution is working well and resolves this ticket smoothly, but it is a bit hacky. However, this solution is clear and effective. Can we apply it? I will write a comment to explain why we used it and how it works. |
thank you, @QichenZhu . I will try this |
thanks, @QichenZhu for recommend. I tested it that work. Proposal updated@eh2077 could you check my new solution? |
@QichenZhu Thank you for your input! @huult Thanks for the update! I'll take a look tmr. |
Triggered auto assignment to @lakchote, see https://stackoverflow.com/c/expensify/questions/7972 for more details. |
@huult's proposal with |
📣 @huult 🎉 An offer has been automatically sent to your Upwork account for the Contributor role 🎉 Thanks for contributing to the Expensify app! Offer link |
If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!
Version Number: 9.0.99-0
Reproducible in staging?: Y
Reproducible in production?: Y
If this was caught on HybridApp, is this reproducible on New Expensify Standalone?: Y
If this was caught during regression testing, add the test name, ID and link from TestRail: N/A
Issue reported by: Applause - Internal Team
Action Performed:
Expected Result:
After a digit, entering dot must not move the first digit while adding tax rate
Actual Result:
After a digit, entering dot moves the first digit while adding tax rate
Workaround:
Unknown
Platforms:
Which of our officially supported platforms is this issue occurring on?
Screenshots/Videos
Add any screenshot/video evidence
Bug6745800_1739803897453.Screenrecorder-2025-02-17-20-15-48-207.mp4
View all open jobs on GitHub
Upwork Automation - Do Not Edit
Issue Owner
Current Issue Owner: @eh2077The text was updated successfully, but these errors were encountered: