Skip to content

Conversation

@Klakurka
Copy link
Member

@Klakurka Klakurka commented Dec 14, 2025

Related to #1080

Description

PayButton generator not working unless USD value is set.

Test plan

Open the landing page, setup a button using the Button Generator. Click it to open the dialog. Try a bunch of combinations of things. Also make sure dialog closing works as that was broken regardless of if USD was set or not.

Summary by CodeRabbit

  • Bug Fixes
    • Fixed payment button component prop handling for empty input fields. Amount, randomSatoshis, and event callback props now properly reset to undefined when corresponding fields are empty, ensuring cleaner component behavior.

✏️ Tip: You can customize this high-level summary in your review settings.

@Klakurka Klakurka added this to the Phase 3 milestone Dec 14, 2025
@Klakurka Klakurka requested a review from lissavxo December 14, 2025 07:40
@Klakurka Klakurka self-assigned this Dec 14, 2025
@Klakurka Klakurka added the bug Something isn't working label Dec 14, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 14, 2025

Walkthrough

The ButtonGenerator component now conditionally passes props to PayButtonWidget and PayButton. The amount prop becomes undefined when empty instead of always being parsed; randomSatoshis is only passed when amount is non-empty; onOpen and onClose become undefined when their corresponding fields are empty.

Changes

Cohort / File(s) Summary
Conditional Prop Passing
components/ButtonGenerator/index.tsx
Modified amount prop to parse to float only when non-empty (undefined otherwise); randomSatoshis now conditionally passed only when amount exists; onOpen and onClose props now conditionally passed based on field state

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

  • Review the conditional logic for each prop assignment to ensure undefined handling matches intended behavior
  • Verify that downstream components correctly handle undefined values for amount, randomSatoshis, onOpen, and onClose

Poem

🐰 Props now dance with grace,
Undefined when empty, they know their place,
Conditional whispers guide the way,
Smart components thrive today! ✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title references a specific fix (PayButton in Button Generator) that aligns with the PR's main objective of fixing the button generator functionality.
Description check ✅ Passed The description includes the required sections (Related to, Description, Test plan) and provides clear context about the bug and validation steps, though it could be more detailed about the technical root cause.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/button-generator-without-usd

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

Comment @coderabbitai help to get the list of available commands and usage tips.

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: 2

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e72861c and 10a56cb.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (1)
  • components/ButtonGenerator/index.tsx (4 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Run Tests
🔇 Additional comments (2)
components/ButtonGenerator/index.tsx (2)

431-432: LGTM! Dialog-closing behavior fix looks correct.

Passing undefined instead of empty strings for onOpen and onClose props correctly addresses the dialog-closing behavior issue mentioned in the PR objectives. This allows the components to handle these callbacks properly when they're not provided.


401-401: Line 401 is correct. Both PayButton and Widget from @paybutton/react expect the amount prop as a string. Line 401 correctly passes button.amount as a string. The type inconsistency actually exists at line 366, where PayButtonWidget incorrectly receives parseFloat(button.amount) (a number) instead of the string value.

Likely an incorrect or invalid review comment.

key={`widget-${JSON.stringify(button)}`}
to={button.to}
amount={parseFloat(button.amount)}
amount={button.amount === '' ? undefined : parseFloat(button.amount)}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Inconsistent checks for amount and randomSatoshis logic.

Line 366 correctly parses amount to float for the widget. However, line 388's check button.amount !== '' is inconsistent with the UI visibility logic at line 325, which uses parseFloat(button.amount) > 0. This mismatch means that if a user enters "0" or "0.0", the randomSatoshis field won't be shown in the form (line 325 returns null), but the prop would still be passed to the component (line 388 would evaluate to true).

Consider aligning the check with the UI visibility logic:

-                  randomSatoshis={button.amount !== '' ? button.randomSatoshis : undefined}
+                  randomSatoshis={parseFloat(button.amount) > 0 ? button.randomSatoshis : undefined}

Also applies to: 388-388

🤖 Prompt for AI Agents
In components/ButtonGenerator/index.tsx around lines 325, 366 and 388, the
visibility logic uses parseFloat(button.amount) > 0 but the prop passing uses
button.amount !== '' which causes a mismatch for "0" values; update the prop
checks to mirror the UI logic by parsing the amount and only treating it as
present when parseFloat(amount) > 0, i.e. pass amount={parseFloat(button.amount)
> 0 ? parseFloat(button.amount) : undefined} and set randomSatoshis to be passed
only when parseFloat(button.amount) > 0 (handle NaN by treating non-numeric or
<=0 as absent), ensuring consistent behavior and guarding with Number.isFinite
or isNaN checks.

: button.onTransaction
}
randomSatoshis={button.randomSatoshis}
randomSatoshis={button.amount !== '' ? button.randomSatoshis : undefined}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Inconsistent check for randomSatoshis (same as line 388).

The check button.amount !== '' is inconsistent with the UI visibility logic at line 325 (parseFloat(button.amount) > 0). This could cause the prop to be passed even when the form field is hidden (e.g., when amount is "0").

Apply the same fix as suggested for line 388:

-                  randomSatoshis={button.amount !== '' ? button.randomSatoshis : undefined}
+                  randomSatoshis={parseFloat(button.amount) > 0 ? button.randomSatoshis : undefined}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
randomSatoshis={button.amount !== '' ? button.randomSatoshis : undefined}
randomSatoshis={parseFloat(button.amount) > 0 ? button.randomSatoshis : undefined}
🤖 Prompt for AI Agents
In components/ButtonGenerator/index.tsx around line 423, the prop randomSatoshis
is conditionally passed using button.amount !== '' which is inconsistent with
the UI visibility check (parseFloat(button.amount) > 0); change the condition to
use parseFloat(button.amount) > 0 so randomSatoshis is only passed when the
numeric amount is greater than zero (i.e., replace the current check with the
same parseFloat(button.amount) > 0 guard used elsewhere).

@Klakurka Klakurka linked an issue Dec 15, 2025 that may be closed by this pull request
@Klakurka Klakurka merged commit daa1cd7 into master Dec 16, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PayButton generator not working unless USD value is set

3 participants