[PR #394] [MERGED] fix(useSheetValue): default value should be null not undefined #93001

Closed
opened 2026-05-26 05:12:19 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/actualbudget/actual/pull/394
Author: @MatissJanis
Created: 11/20/2022
Status: Merged
Merged: 11/21/2022
Merged by: @jlongster

Base: masterHead: matiss/fix-reconciliation


📝 Commits (2)

  • d39cb9e fix(useSheetValue): default value should be null not undefined
  • 745e734 fix: add default value to be even more secure against future regressions

📊 Changes

2 files changed (+2 additions, -1 deletions)

View changed files

📝 packages/desktop-client/src/components/accounts/Account.js (+1 -0)
📝 packages/loot-design/src/components/spreadsheet/useSheetValue.js (+1 -1)

📄 Description

Fixes #393


Problem: clicking on "reconcile" causes a fatal page crash.

Issue:
by default useSheetValue returns undefined value.

In the calculations we use cleared balance minus targetBalance (customer input) to calculate targetDiff. If cleared is undefined, we end up with targetBalance === NaN.

targetBalance later is used in the format() util function. This function expects number values and not a NaN.

4904da5006/packages/desktop-client/src/components/accounts/Account.js (L107-L111)

Fix:
The simple fix is to return null by default in useSheetValue. null is already used as a default value for string-type bindings here, so IMO this change is safe to be applied.

console.log(100 - null) // 100
console.log(100 - undefined) // NaN

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/actualbudget/actual/pull/394 **Author:** [@MatissJanis](https://github.com/MatissJanis) **Created:** 11/20/2022 **Status:** ✅ Merged **Merged:** 11/21/2022 **Merged by:** [@jlongster](https://github.com/jlongster) **Base:** `master` ← **Head:** `matiss/fix-reconciliation` --- ### 📝 Commits (2) - [`d39cb9e`](https://github.com/actualbudget/actual/commit/d39cb9eac53a3ca5858a0bd89d4ee3918c4725c4) fix(useSheetValue): default value should be null not undefined - [`745e734`](https://github.com/actualbudget/actual/commit/745e734519aae35f28b07450ff8946193152d269) fix: add default value to be even more secure against future regressions ### 📊 Changes **2 files changed** (+2 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `packages/desktop-client/src/components/accounts/Account.js` (+1 -0) 📝 `packages/loot-design/src/components/spreadsheet/useSheetValue.js` (+1 -1) </details> ### 📄 Description Fixes #393 --- **Problem:** clicking on "reconcile" causes a fatal page crash. **Issue:** by default `useSheetValue` returns `undefined` value. In the calculations we use `cleared` balance minus `targetBalance` (customer input) to calculate `targetDiff`. If `cleared` is `undefined`, we end up with `targetBalance === NaN`. `targetBalance` later is used in the `format()` util function. This function expects number values and not a `NaN`. https://github.com/MatissJanis/actual/blob/4904da500672f11d28bc47ddedfbaaae94b96aeb/packages/desktop-client/src/components/accounts/Account.js#L107-L111 **Fix:** The simple fix is to return `null` by default in `useSheetValue`. `null` is already used as a default value for `string`-type bindings [here](https://github.com/MatissJanis/actual/blob/master/packages/loot-design/src/components/spreadsheet/useSheetValue.js#L25-L26), so IMO this change is safe to be applied. ``` console.log(100 - null) // 100 console.log(100 - undefined) // NaN ``` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-05-26 05:12:19 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/actual#93001