selectmodal bug fixed#1106
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes the Deposit flow’s asset selector flicker (Issue #1098) by guarding against rapid double-clicks causing duplicate selection/close state transitions in SelectModal.
Changes:
- Added a
useRef-based “selection in progress” guard to ignore repeated selection handler invocations. - Reset the guard when the modal opens (
isOpenbecomestrue) to allow selection in the next open session.
|
I feel that we might need to look deeper into the problem as I don't want to fix symptoms instead of the root cause. Also, the issue itself is quite odd in the first place, so I don't want to bring a symptomatic hotfix for the issue that only occurs if the user does some odd things. As pointed out by Copilot review, this hotfix did not account for the multiselect case and as such this fix for a corner case would break a multiselect case, which is a much more severe problem, and who knows what else would it break. |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
| // Reset the guard whenever the modal opens so it's ready for the next session. | ||
| useEffect(() => { | ||
| if (isOpen) { | ||
| isSelectingRef.current = false; | ||
| } | ||
| }, [isOpen]); |
| // Prevent a rapid double-click from triggering the handler twice (single-select only). | ||
| // For multi-select we must allow multiple item clicks while the modal remains open. | ||
| if (!multiSelect) { | ||
| if (isSelectingRef.current) return; | ||
| isSelectingRef.current = true; |
frol
left a comment
There was a problem hiding this comment.
See my comment and the Copilot review as well
fixes #1098
two changes made in select-modal
useRef(false) flag that is set to true on first invocation , immediately any subsequent calls while the flag is set to true
& useEffect resets to false whenever isOpen becomes true
Screen.Recording.2026-07-14.at.12.02.24.PM.mov