fix: preserve explicit zero in numeric config defaults and order totals#89
Merged
paulobernardoaf merged 1 commit intomainfrom Apr 17, 2026
Merged
Conversation
Replace `||` fallbacks with `??` so callers passing `0` are not silently
overridden by the default value:
- `standalone.jsx` (`mapConfig`):
- `renderPercentage`: `0` now reaches the service so the widget can be
hidden on purpose instead of always rendering
- `tooltipDelay`: `0` now means "show immediately" instead of `500`
- `MessageOrder`: product items with `quantity: 0` no longer contribute
`1` to the total item count
Made-with: Cursor
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #89 +/- ##
=======================================
Coverage 66.14% 66.14%
=======================================
Files 71 71
Lines 3096 3096
Branches 837 854 +17
=======================================
Hits 2048 2048
+ Misses 1021 1020 -1
- Partials 27 28 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
cristiantela
approved these changes
Apr 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replace
||fallbacks with??in three places where0was being silently overridden by the default, because JavaScript's logical OR treats0as falsy.src/standalone.jsx→mapConfigrenderPercentage: passing0(intended to hide the widget) was being converted to100, so the webchat always rendered. Now0reaches the service andshouldRendercorrectly resolves tofalse.tooltipDelay: passing0was being converted to500, so there was no way to show the tooltip immediately. Now0is respected.src/components/Messages/MessageOrder.jsxquantity: 0as1. It now contributes0, while still defaulting missing/undefinedquantities to1.Root cause
All three cases relied on
value || default, which falls back on any falsy value including0. Nullish coalescing (value ?? default) only falls back onnull/undefined, preserving explicit zeros.Test plan
renderPercentage: 0→ widget does not render.renderPercentage: 100(or omitted) → widget renders as before.tooltipDelay: 0and atooltipMessage→ tooltip appears immediately.tooltipDelayomitted → tooltip still defaults to 500 ms.MessageOrderwith aproduct_itemsentry wherequantity: 0→ total is0.MessageOrderwith aproduct_itemsentry wherequantityis missing → total defaults to1per item (existing behavior).Made with Cursor