stack/apps
BilalG1 33a7ef5485
Fix item quantity dialog balance preview flicker on submit (#1774)
## Problem

On a customer's payments view, submitting a manual item quantity change
makes the "New balance: X → Y" preview in the dialog briefly flip to the
post-change values (e.g. `0 → 10` flashes to `10 → 20`) right before the
dialog closes.

## Root cause

The preview was computed from the live `currentQuantity` prop, which
comes from `useItem()` in the parent row. The SDK's
`createItemQuantityChange` awaits its item cache refresh before
resolving, so the prop updates to the new quantity while the dialog is
still open (and stays visible through the close animation), recomputing
the preview with stale input text.

## Fix

Snapshot the quantity when the dialog opens (in the existing
reset-on-open effect) and compute the preview from the snapshot instead
of the live prop. The preview now consistently shows the balance as of
when the dialog was opened.

## Before vs after

Recorded against built servers (before = `dev`, after = this branch).
The transactions refetch is artificially delayed by 5s in both
recordings to stretch the flicker window to a visible length — on
production latency it's a split-second flash.



https://github.com/user-attachments/assets/c005ef3b-45cb-4b75-bd71-5f723eae0c50



## Tradeoffs

If the quantity changes externally while the dialog is open, the preview
shows the value from open time. The mutation is a delta, so correctness
of the applied change is unaffected.


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Bug Fixes**
  * Stabilized the quantity change preview while the dialog is open.
* The “New balance” display now consistently shows the quantity at
opening and the calculated updated quantity, even if underlying values
change during submission.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-07-17 09:09:15 -07:00
..
backend Fix recurring production Sentry errors (#1768) 2026-07-16 17:20:49 -07:00
bulldozer-js Make Bulldozer Studio log less 2026-07-10 11:02:18 -07:00
dashboard Fix item quantity dialog balance preview flicker on submit (#1774) 2026-07-17 09:09:15 -07:00
dev-launchpad chore: update package versions 2026-07-06 23:34:27 +00:00
e2e Fix recurring production Sentry errors (#1768) 2026-07-16 17:20:49 -07:00
hosted-components chore: update package versions 2026-07-06 23:34:27 +00:00
internal-tool chore: update package versions 2026-07-06 23:34:27 +00:00
mcp chore: update package versions 2026-07-06 23:34:27 +00:00
mock-oauth-server chore: update package versions 2026-07-06 23:34:27 +00:00
oauth-mock-server In-source unit tests (#429) 2025-02-14 11:47:52 -08:00
skills chore: update package versions 2026-07-06 23:34:27 +00:00