Skip to content

Prop key to update value every time button is clicked#2707

Open
pory-gone wants to merge 4 commits intostackernews:masterfrom
pory-gone:zap_suggestion
Open

Prop key to update value every time button is clicked#2707
pory-gone wants to merge 4 commits intostackernews:masterfrom
pory-gone:zap_suggestion

Conversation

@pory-gone
Copy link
Contributor

Description

closes #2703

Fixed forcing input remounting via a prop key that is updated every time the suggestion is clicked, so the value is always updated even when selecting the same option.

Screenshots

Video.del.2025-12-24.15-22-40.mp4

Additional Context

Checklist

Are your changes backward compatible? Please answer below:
Yes

For example, a change is not backward compatible if you removed a GraphQL field or dropped a database column.

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:
8/10

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

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

Did you use AI for this? If so, how much did it assist you?
AI was not used for fixing this bug

@pory-gone pory-gone marked this pull request as ready for review December 24, 2025 14:25
Copy link
Member

@huumn huumn left a comment

Choose a reason for hiding this comment

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

This works!

It's a bit of a hack though, which is cool when we can't find an alternative, but there is an alternative here.

Spoiler Alert: the alternative

Define the onChange handler of Input and setOValue(undefined) when called.

This bug exists because overrideValue works as a dependency in a useEffect that overrides the form's input value. So when the same overrideValue is passed, the useEffect in Input does not run.

By unsetting oValue when the input value changes in response to user input, the useEffect will run when the oValue is set again.

@pory-gone
Copy link
Contributor Author

hello! First of all, Happy Christmas Eve to the SN team. I apologize for taking the "easy way out" with this little trick. I'll correct it as you explained as soon as possible.

@huumn
Copy link
Member

huumn commented Dec 25, 2025

Merry Christmas Pory!

@pory-gone pory-gone requested a review from huumn December 25, 2025 10:41
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