Fix multiple execution of onSubmit function from FormProvider#53219
Fix multiple execution of onSubmit function from FormProvider#53219ChavdaSachin wants to merge 5 commits intoExpensify:mainfrom
Conversation
|
Hey! I see that you made changes to our Form component. Make sure to update the docs in FORMS.md accordingly. Cheers! |
| isSubmittingRef.current = true; | ||
| KeyboardUtils.dismiss().then(() => onSubmit(trimmedStringValues)); | ||
|
|
||
| return () => (isSubmittingRef.current = false); |
There was a problem hiding this comment.
Well, wait, this callback will never be executed, because it's not a useEffect (it's useCallback and useCallback doesn't fire internal callbacks). Correct me if I'm wrong.
There was a problem hiding this comment.
@ChavdaSachin I think a slightly better approach would be to use useDebounce hook with interval 500ms? What do you think about it?
There was a problem hiding this comment.
@kirillzyusko in that case I tried various methods , even async - await mechanism and KeyboardUtils.dismiss().then(() => onSubmit(trimmedStringValues)).finally(isSubmittingRef.current=false); but problem stays,
The only option worked for me was not resetting the value(note. all the onSubmit functions are associated with some sort of navigation, so it's working, and useSingleExecution hook also).
If that sounds an unacceptable solution then please take over the issue, sorry for the inconvenience in that case.
There was a problem hiding this comment.
Thanks @ChavdaSachin for your attempts to solve this problem, appreciate it!
In the end we decided to go in a slightly different way: #53227
Explanation of Change
Fixed Issues
$ #53152
PROPOSAL: #53152 (comment)
Tests
Offline tests
QA Steps
// TODO: These must be filled out, or the issue title must include "[No QA]."
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
MacOS: Desktop