-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
fix: reapply thousand separators before passing input to appendDecimals #5220
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
fix: reapply thousand separators before passing input to appendDecimals #5220
Conversation
✅ Deploy Preview for actualbudget ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Bundle Stats — desktop-clientHey there, this message comes from a GitHub action that helps you and reviewers to understand how these changes affect the size of this project's bundle. As this PR is updated, I'll keep you updated on how the bundle size is impacted. Total
Changeset
View detailed bundle breakdownAdded No assets were added Removed No assets were removed Bigger
Smaller No assets were smaller Unchanged
|
Bundle Stats — loot-coreHey there, this message comes from a GitHub action that helps you and reviewers to understand how these changes affect the size of this project's bundle. As this PR is updated, I'll keep you updated on how the bundle size is impacted. Total
Changeset
View detailed bundle breakdownAdded No assets were added Removed No assets were removed Bigger No assets were bigger Smaller No assets were smaller Unchanged
|
fabac9b
to
8d6d966
Compare
This ensures that the input going into `appendDecimals` is not malformed when the `hideFraction` option is On, otherwise when hitting delete on the text `"1,234,567"`, it will result in the text `"1,234,56"` which the formatter will parse as `1234.56`. This doesn't happen when `hideFraction` is off since hitting delete on the text `"12,345.67"` results in `"12,345.6"`, which `appendDecimals` will happily handle in a separate case to provide `"1234.56"` as the input into `currencyToAmount`.
8d6d966
to
0db8caf
Compare
""" WalkthroughThe changes introduce a new utility function Assessment against linked issues
Suggested labels
Suggested reviewers
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms (7)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
upcoming-release-notes/5220.md
is excluded by!**/*.md
📒 Files selected for processing (3)
packages/desktop-client/src/components/mobile/transactions/FocusableAmountInput.tsx
(2 hunks)packages/desktop-client/src/components/util/AmountInput.tsx
(2 hunks)packages/loot-core/src/shared/util.ts
(1 hunks)
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
Learnt from: misu-dev
PR: actualbudget/actual#5167
File: packages/desktop-client/src/components/spreadsheet/useFormat.ts:222-229
Timestamp: 2025-06-14T20:50:58.830Z
Learning: The `currencyToAmount` function in `loot-core/shared/util.ts` converts currency strings (like "3.14") directly to numeric amounts (3.14) without taking decimal places as a parameter. It only parses the string format and does not handle decimal place scaling - that happens downstream in functions like `amountToInteger` and `fromAmount`.
packages/desktop-client/src/components/mobile/transactions/FocusableAmountInput.tsx (1)
Learnt from: misu-dev
PR: actualbudget/actual#5167
File: packages/desktop-client/src/components/spreadsheet/useFormat.ts:222-229
Timestamp: 2025-06-14T20:50:58.830Z
Learning: The `currencyToAmount` function in `loot-core/shared/util.ts` converts currency strings (like "3.14") directly to numeric amounts (3.14) without taking decimal places as a parameter. It only parses the string format and does not handle decimal place scaling - that happens downstream in functions like `amountToInteger` and `fromAmount`.
packages/loot-core/src/shared/util.ts (1)
Learnt from: misu-dev
PR: actualbudget/actual#5167
File: packages/desktop-client/src/components/spreadsheet/useFormat.ts:222-229
Timestamp: 2025-06-14T20:50:58.830Z
Learning: The `currencyToAmount` function in `loot-core/shared/util.ts` converts currency strings (like "3.14") directly to numeric amounts (3.14) without taking decimal places as a parameter. It only parses the string format and does not handle decimal place scaling - that happens downstream in functions like `amountToInteger` and `fromAmount`.
🧬 Code Graph Analysis (1)
packages/desktop-client/src/components/util/AmountInput.tsx (1)
packages/loot-core/src/shared/util.ts (1)
reapplyThousandSeparators
(217-226)
🔇 Additional comments (4)
packages/desktop-client/src/components/mobile/transactions/FocusableAmountInput.tsx (2)
22-22
: LGTM: Import added correctly.The import statement properly includes the new
reapplyThousandSeparators
utility function.
117-117
: LGTM: Proper integration of thousand separator normalization.The
reapplyThousandSeparators
function is correctly placed beforeappendDecimals
, which aligns with the PR objective to fix malformed input parsing whenhideFraction
is enabled. This will ensure that input like "1,234,56" gets normalized to "123,456" before further processing.packages/desktop-client/src/components/util/AmountInput.tsx (2)
21-25
: LGTM: Import statement updated correctly.The import statement properly includes the new
reapplyThousandSeparators
utility function alongside existing imports.
103-103
: LGTM: Consistent integration across AmountInput components.The
reapplyThousandSeparators
function is correctly integrated before the conditionalappendDecimals
call, ensuring consistent thousand separator handling across both desktop and mobile AmountInput components. This maintains the fix for malformed input parsing throughout the application.
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Sorry if it disrupted the PR's tags, I was just correcting the description. |
FYI, this has caused issue #5266. It may only be for certain browsers. |
Fixes #5218
This ensures that the input going into
appendDecimals
is not malformed when thehideFraction
option is On, otherwise when hitting delete on the text"1,234,567"
, it will result in the text"1,234,56"
which the formatter will parse as1234.56
. This doesn't happen whenhideFraction
is off since hitting delete on the text"12,345.67"
results in"12,345.6"
, whichappendDecimals
will happily handle in a separate case to provide"12345.6"
as the input intocurrencyToAmount
.