Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix amount reset #32884

Merged
merged 1 commit into from
Dec 12, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/pages/iou/steps/MoneyRequestAmountForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,9 @@ function MoneyRequestAmountForm({amount, currency, isEditing, forwardedRef, onCu
return;
}
initializeAmount(amount);
// we want to update the state only when the amount is changed
// we want to re-initialize the state only when the selected tab changes
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [amount]);
}, [selectedTab]);
Copy link
Contributor

Choose a reason for hiding this comment

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

Was there any reason for removing amount from dependency?
It caused #33125 and #33123

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We discussed this internally and thought it made sense to only initialize the amount when the tab changes since that's the intended behavior. It seems like the code was coupled elsewhere though which caused the regressions above.

Copy link
Contributor

@situchan situchan Jan 8, 2024

Choose a reason for hiding this comment

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

ok, so it's fine to add this back? I don't find any side effect after this.

    }, [amount, selectedTab]);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yea, I think it's ok as long as the amount still resets when the tab is switched


/**
* Sets the selection and the amount accordingly to the value passed to the input
Expand Down