Skip to content

Conversation

intagaming
Copy link
Contributor

@intagaming intagaming commented Jun 22, 2025

Fixes #5218

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 "12345.6" as the input into currencyToAmount.

Copy link

netlify bot commented Jun 22, 2025

Deploy Preview for actualbudget ready!

Name Link
🔨 Latest commit e202224
🔍 Latest deploy log https://app.netlify.com/projects/actualbudget/deploys/685fef1544a1c00008e52162
😎 Deploy Preview https://deploy-preview-5220.demo.actualbudget.org
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link
Contributor

github-actions bot commented Jun 22, 2025

Bundle Stats — desktop-client

Hey 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

Files count Total bundle size % Changed
20 10.08 MB → 10.08 MB (+689 B) +0.01%
Changeset
File Δ Size
home/runner/work/actual/actual/packages/loot-core/src/shared/util.ts 📈 +601 B (+7.96%) 7.38 kB → 7.96 kB
src/components/util/AmountInput.tsx 📈 +42 B (+0.86%) 4.79 kB → 4.84 kB
src/components/mobile/transactions/FocusableAmountInput.tsx 📈 +46 B (+0.75%) 5.98 kB → 6.03 kB
View detailed bundle breakdown

Added

No assets were added

Removed

No assets were removed

Bigger

Asset File Size % Changed
static/js/index.js 7.58 MB → 7.58 MB (+689 B) +0.01%

Smaller

No assets were smaller

Unchanged

Asset File Size % Changed
static/js/de.js 129.46 kB 0%
static/js/en-GB.js 6.38 kB 0%
static/js/en.js 121.16 kB 0%
static/js/es.js 70.83 kB 0%
static/js/fr.js 131.54 kB 0%
static/js/nl.js 100.34 kB 0%
static/js/pt-BR.js 124.38 kB 0%
static/js/sv.js 65.13 kB 0%
static/js/th.js 190.63 kB 0%
static/js/uk.js 121.11 kB 0%
static/js/indexeddb-main-thread-worker-e59fee74.js 12.94 kB 0%
static/js/workbox-window.prod.es5.js 5.64 kB 0%
static/js/resize-observer.js 18.37 kB 0%
static/js/BackgroundImage.js 122.29 kB 0%
static/js/ReportRouter.js 820.13 kB 0%
static/js/narrow.js 392.43 kB 0%
static/js/wide.js 115.2 kB 0%
static/js/TransactionList.js 10.92 kB 0%
static/js/useAccountPreviewTransactions.js 3.15 kB 0%

Copy link
Contributor

github-actions bot commented Jun 22, 2025

Bundle Stats — loot-core

Hey 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

Files count Total bundle size % Changed
1 2.25 MB 0%
Changeset
File Δ Size
packages/loot-core/src/shared/util.ts 📈 +670 B (+5.62%) 11.64 kB → 12.29 kB
View detailed bundle breakdown

Added

No assets were added

Removed

No assets were removed

Bigger

No assets were bigger

Smaller

No assets were smaller

Unchanged

Asset File Size % Changed
kcab.worker.js 2.25 MB 0%

@intagaming intagaming force-pushed the fix-hide-decimals-delete branch from fabac9b to 8d6d966 Compare June 22, 2025 03:11
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`.
@intagaming intagaming force-pushed the fix-hide-decimals-delete branch from 8d6d966 to 0db8caf Compare June 22, 2025 03:17
@intagaming intagaming marked this pull request as ready for review June 22, 2025 03:29
Copy link
Contributor

coderabbitai bot commented Jun 22, 2025

"""

Walkthrough

The changes introduce a new utility function reapplyThousandSeparators in packages/loot-core/src/shared/util.ts. This function normalizes and reapplies thousand separators to numeric strings according to the user's locale. The function is then integrated into the onInputTextChange handler of the AmountInput component and the onChangeText handler of the FocusableAmountInput component. In both locations, the input value is processed by reapplyThousandSeparators before any further formatting or state updates occur. No other logic or exported entity signatures are changed.

Assessment against linked issues

Objective Addressed Explanation
Fix input handling so that deleting a digit in "Hide decimal places" mode with "1,000" format does not remove extra digits (Issue #5218)
Implement a function to reapply thousand separators to the input string before further processing (Issue #5218)
Integrate the thousand separator normalization into the relevant input handlers for transaction amounts (Issue #5218)

Suggested labels

:white_check_mark: Approved

Suggested reviewers

  • jfdoming
  • matt-fidd
  • MikesGlitch
    """

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0db8caf and 81baa56.

📒 Files selected for processing (1)
  • packages/loot-core/src/shared/util.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/loot-core/src/shared/util.ts
⏰ Context from checks skipped due to timeout of 90000ms (7)
  • GitHub Check: Functional
  • GitHub Check: Visual regression
  • GitHub Check: build (macos-latest)
  • GitHub Check: build (ubuntu-latest)
  • GitHub Check: build (windows-latest)
  • GitHub Check: Functional Desktop App
  • GitHub Check: Analyze
✨ Finishing Touches
  • 📝 Generate Docstrings

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need 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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

📥 Commits

Reviewing files that changed from the base of the PR and between 9478707 and 0db8caf.

⛔ 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 before appendDecimals, which aligns with the PR objective to fix malformed input parsing when hideFraction 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 conditional appendDecimals call, ensuring consistent thousand separator handling across both desktop and mobile AmountInput components. This maintains the fix for malformed input parsing throughout the application.

intagaming and others added 2 commits June 22, 2025 10:35
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@youngcw youngcw added this to the v25.7.0 milestone Jun 25, 2025
@intagaming
Copy link
Contributor Author

Sorry if it disrupted the PR's tags, I was just correcting the description.

@youngcw youngcw merged commit 94a76a0 into actualbudget:master Jun 28, 2025
24 checks passed
@youngcw
Copy link
Member

youngcw commented Jul 2, 2025

FYI, this has caused issue #5266. It may only be for certain browsers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Mobile: "Hide decimal places" and delete 1 digit results in deleting 3 digits for certain number formattings
3 participants