Skip to content

fix(zap): tip suggestions always insert via formik setFieldValue - #3223

Closed
okukkiti wants to merge 1 commit into
stackernews:masterfrom
okukkiti:fix-zap-tips-2703
Closed

fix(zap): tip suggestions always insert via formik setFieldValue#3223
okukkiti wants to merge 1 commit into
stackernews:masterfrom
okukkiti:fix-zap-tips-2703

Conversation

@okukkiti

@okukkiti okukkiti commented Sep 8, 2026

Copy link
Copy Markdown

Description

Fixes #2703.

Spent a while staring at this one. The tip buttons (100, 1000, etc.) go through this weird dance: click sets an oValue state, then a useEffect watching [overrideValue] in form.js picks it up and writes it into the field. Problem is, if you click 100, then something else, then 100 again, React sees the same value and just skips the effect. Field keeps whatever was there before. Easy to miss because the first click always works.

I ripped out the middleman. The buttons now call formik.setFieldValue('amount', num) directly, so every click lands no matter what. Deleted the oValue state and the overrideValue prop. Nothing else imports Tips, checked.

Screenshots

Nothing to show, looks identical. Ran through the issue repro (100, change, 100) plus a few repeats, every click sticks now.

Additional Context

Saw #3165 tried the same approach and got closed. Difference here is I kept it to one commit and actually filled out this template.

Checklist

Are your changes backward compatible? Please answer below:

Yeah, same component, same props from the outside. Just internal wiring.

On a scale of 1-10 how well and how have you QA'd this change and any features it might affect? Please answer below:

  1. Couldn't boot the full app here (heavy repo, small box), but I verified the diff statically, simulated the exact repro, and confirmed no other file touches Tips or oValue.

For frontend changes: Tested on mobile, light and dark mode? Please answer below:

No CSS changed at all, so nothing to screenshot. Event wiring only.

Did you introduce any new environment variables? If so, call them out explicitly here:

No.

Did you use AI for this? If so, how much did it assist you?

Yeah, used AI to help track down the state flow and sanity-check the patch. Reviewed everything before pushing.

Clicking a zap amount suggestion twice in a row (e.g. 100, change,
100) did nothing the second time: the tip buttons wrote through an
intermediate oValue state consumed by a useEffect keyed on
[overrideValue], so React skipped the effect when the value was
unchanged and the field kept the stale amount.

Write directly with formik.setFieldValue('amount', num) instead: every
click inserts, including repeats. Removes the oValue state and the
overrideValue prop.

Fixes stackernews#2703
@huumn huumn closed this Sep 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot click the same zap suggestion more than once

2 participants