-
Notifications
You must be signed in to change notification settings - Fork 3k
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
[CP Staging] fix: store selected currency in URL query temporarily #32851
Merged
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
bd05a4d
fix: store selected currency in URL query temporarily
sangar-1028 de583c8
fix: navigate when selecting currency
sangar-1028 83689f9
Merge branch 'main' into fix/issue-32826
sangar-1028 e70f1e9
fix: use || instead of ?? operator
sangar-1028 f32d7d8
fix: don't store currency data only for confirm page
sangar-1028 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,6 @@ import useLocalize from '@hooks/useLocalize'; | |
import compose from '@libs/compose'; | ||
import * as CurrencyUtils from '@libs/CurrencyUtils'; | ||
import Navigation from '@libs/Navigation/Navigation'; | ||
import * as IOU from '@userActions/IOU'; | ||
import ONYXKEYS from '@src/ONYXKEYS'; | ||
import ROUTES, {getUrlWithBackToParam} from '@src/ROUTES'; | ||
import IOURequestStepRoutePropTypes from './IOURequestStepRoutePropTypes'; | ||
|
@@ -59,14 +58,18 @@ function IOURequestStepCurrency({ | |
const [searchValue, setSearchValue] = useState(''); | ||
const optionsSelectorRef = useRef(); | ||
|
||
const navigateBack = () => { | ||
const navigateBack = (selectedCurrency = undefined) => { | ||
// If the currency selection was done from the confirmation step (eg. + > request money > manual > confirm > amount > currency) | ||
// then the user needs taken back to the confirmation page instead of the initial amount page. This is because the route params | ||
// are only able to handle one backTo param at a time and the user needs to go back to the amount page before going back | ||
// to the confirmation page | ||
if (pageIndex === 'confirm') { | ||
const routeToAmountPageWithConfirmationAsBackTo = getUrlWithBackToParam(backTo, `/${ROUTES.MONEY_REQUEST_STEP_CONFIRMATION.getRoute(iouType, transactionID, reportID)}`); | ||
Navigation.goBack(routeToAmountPageWithConfirmationAsBackTo); | ||
if (selectedCurrency) { | ||
Navigation.navigate(`${routeToAmountPageWithConfirmationAsBackTo}¤cy=${selectedCurrency}`); | ||
} else { | ||
Navigation.goBack(routeToAmountPageWithConfirmationAsBackTo); | ||
} | ||
return; | ||
} | ||
Navigation.goBack(backTo || ROUTES.HOME); | ||
|
@@ -78,8 +81,7 @@ function IOURequestStepCurrency({ | |
*/ | ||
const confirmCurrencySelection = (option) => { | ||
Keyboard.dismiss(); | ||
IOU.setMoneyRequestCurrency_temporaryForRefactor(transactionID, option.currencyCode); | ||
navigateBack(); | ||
navigateBack(option.currencyCode); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A minor UI issue here. As we navigate back without ensuring that the Onyx has indeed updated the new currency, the new currency does not immediately get displayed in the previous screen. This resulted in issue #41515 |
||
}; | ||
|
||
const {sections, headerMessage, initiallyFocusedOptionKey} = useMemo(() => { | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should disable this lint rule
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@luacmartins Do you suggest to use
||
operator?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I replaced the operator. Will you check again?