Prop key to update value every time button is clicked#2707
Prop key to update value every time button is clicked#2707pory-gone wants to merge 4 commits intostackernews:masterfrom
Conversation
huumn
left a comment
There was a problem hiding this comment.
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.
|
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. |
|
Merry Christmas Pory! |
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