fix(zap): tip suggestions always insert via formik setFieldValue - #3223
Closed
okukkiti wants to merge 1 commit into
Closed
fix(zap): tip suggestions always insert via formik setFieldValue#3223okukkiti wants to merge 1 commit into
okukkiti wants to merge 1 commit into
Conversation
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
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.
Description
Fixes #2703.
Spent a while staring at this one. The tip buttons (100, 1000, etc.) go through this weird dance: click sets an
oValuestate, then auseEffectwatching[overrideValue]inform.jspicks 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 theoValuestate and theoverrideValueprop. Nothing else importsTips, 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:
TipsoroValue.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.