-
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
[HOLD App#22901] Fix/address page state navigation #29053
[HOLD App#22901] Fix/address page state navigation #29053
Conversation
Hey! I see that you made changes to our Form component. Make sure to update the docs in FORMS.md accordingly. Cheers! |
@parasharrajat Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
@parasharrajat I have made the changes. Will soon add the screenshots and complete the checklist. I'd like to hightlight a minor issue: Regarding 2023-09-26_16-04-04_output_trimmed.mp4 |
@ygshbht I really didn't understand from your comment what is the issue. Before and after look same. Are you saying that after changing the country the state picker that was filled shows an error? I think this is because the form input remains dirty even after we clear it on the setting country. We should reset its state when changed programmatically. Let me test it first. |
@@ -164,6 +174,8 @@ function AdditionalDetailsStep({walletAdditionalDetails, translate, currentUserP | |||
); | |||
} | |||
|
|||
const state = getStateFromRoute(route); |
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.
let's use useRoute
hook instead.
Yes. Because the state field has been touched, the error ("this field is required") is shown after you change the country and set state to empty string |
@parasharrajat Yes, it should be fixed now. If you see any issue, please let me know |
@ygshbht I have been tracking https://github.com/Expensify/App/pull/27836/files PR which seems to implement a similar picker but in a generic way. I am hoping that we can reuse that component in our PR. Unfortunately, there is a bug in that PR thus we reverted that PR. But It is hoped to be remerged soon. Do you think we can wait on that and reuse logic? |
@parasharrajat, I'm not sure. Upon reviewing the files, it seems that the change is a replacement for the |
Thanks for the response. I will analyze the code myself and try to outline the possible changes. I agree let's do this only when it is a quick change. |
Okay, so ValuePicker on that PR is using the Old pattern which we are migrating away so we are good. I think I will report a new issue to migrate those to the new pattern as well. But it gave me an idea. Can we use a similar valueSelector component that replaces both CountrySelector and StateSelector? Maybe we can control the type via props. Can you analyze this? @ygshbht |
@parasharrajat |
Apologies for the delay. Your comment makes sense. I will get this finalized tomorrow. |
bump @parasharrajat |
src/libs/getStateFromRoute.ts
Outdated
params?: Record<string, any>; | ||
}; | ||
|
||
export default function getStateFromRoute(route: RouteProps, stateParamName = 'state'): string { |
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.
Why do we have to create a separate hook? I think the logic can be moved in useGeographicalStateFromRoute
itself.
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.
Yeah, that was being used at mulitple places before i created useGeographicalStateFromRoute
. Have removed it
@parasharrajat Updated. I've also removed StateSelector logic of getting param from URL in various files and also fixed autocomplete bug for state if you want to test |
@ygshbht Can you please merge main again? We has a major refactor on main. |
@parasharrajat Done |
src/ROUTES.ts
Outdated
route += `&label=${encodeURIComponent(label)}`; | ||
} | ||
if (stateParamName) { | ||
route += `&stateParamName=${encodeURIComponent(stateParamName)}`; |
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.
what is the purpose of this?
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.
To distinguish state values for cases when there are more than one state selectors in one page e.g Company step in Reimbursement flow.
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 think we can hold this on changes done here #22901 as I believe we will not have two state pickers on one page ever
src/components/StateSelector.js
Outdated
forwardedRef: PropTypes.func, | ||
|
||
/** Label of state in the url */ | ||
paramName: PropTypes.string, |
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.
paramName: PropTypes.string, | |
queryParam: PropTypes.string, |
src/components/StateSelector.js
Outdated
inputID: PropTypes.string.isRequired, | ||
|
||
/** React ref being forwarded to the MenuItemWithTopDescription */ | ||
forwardedRef: PropTypes.func, |
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.
forwardedRef: PropTypes.func, | |
forwardedRef: refPropType, |
Please import it.
src/components/StateSelector.js
Outdated
label: PropTypes.string, | ||
|
||
/** whether to use state from url, for cases when url value is passed from parent */ | ||
useStateFromUrl: PropTypes.bool, |
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.
useStateFromUrl: PropTypes.bool, | |
shouldUseStateFromUrl: PropTypes.bool, |
// eslint-disable-next-line you-dont-need-lodash-underscore/get | ||
import lodashGet from 'lodash/get'; |
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.
We can remove the lodash from this code. I don't see any need for it.
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.
Are you sure? Its being used at two places. The code will be longer without it but I'll remove it if you think that's causing any issues
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.
We can use optional chaining from TS instead of lodash. We are trying to get away from it.
Somehow, I forgot to submit the review 2 days back. |
Can you please also merge main into this? |
@mountiny Can you please cross-verify the approach as well? |
* @param {string} paramValue - The value of the query parameter to append or update. | ||
* @returns {string} The updated URL with the appended or updated query parameter. | ||
*/ | ||
function appendParam(url, paramName, paramValue) { |
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 think we should update our navigate function to accept params. It is duplicate work when react-navigation already handles that.
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.
You mean the Navigation.navigate
and Navigation.goBack
functions? Can you please provide a little example of the change you want here?
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.
Technically, this change is out of the scope of this PR. I was just putting the idea.
We can, for now, move this function to a lib for generic use.
@parasharrajat Merged and updated. Please let me know your thoughts on the remaining changes |
@parasharrajat Done |
…migration [TS migration] Migrate 'DistanceEReceipt.js' component to TypeScript
…ards/merchant-required
…tion-profile-page
[FIX]: "PO boxes and mail drop addresses are not allowed" appears twice in Address
[FIX]: "Company type" appears twice in the selection list
…sReportMessageAttachmentTest [No QA] [TS migration] Migrate 'isReportMessageAttachmentTest.js' test to TypeScript
…ify-icons fix: cretae seperated logo for icons
…le-levels-tags Allow for multiple levels of tags on workspace
…rds/merchant-required
Create Add-profile-photo.md
…y-native-attachment-carousel Simplify native attachment gallery paging context and improve code
Conversation scrolling to the beginning of the chat.
…-for-e2e-failures [NoQA] post slack update about failed e2e pipeline to new slack room
Update report description max length to 500
…mistic-flag Ensure isOptimisticReport is set and fix issues with optimistic reports getting deleted on reconnect
…olations/36481-billable-field Move violation message below billable field
…e-state-navigation-new
@parasharrajat I merged fix/address-page-state-navigation into main and then merged main back into fix/address-page-state-navigation. But as you see Github shows a lot of commits. You think i need to create a new PR or can this be fixed somehow? |
@ygshbht yes please, can you create a fresh PR this might be the best path forwards |
Yep, it is here |
Lets close this in favour of #36770 then thank you |
Details
Fixed Issues
$ #23725
PROPOSAL: #23725 (comment)
Tests
Offline tests
Same as tests
QA Steps
Same as tests
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodWaiting for Copy
label for a copy review on the original GH to get the correct copy.STYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)/** comment above it */
this
are necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);
ifthis.submit
is never passed to a component event handler likeonClick
)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.Screenshots/Videos
Web
output_web.mp4
Mobile Web - Chrome
output_android.chrome.mp4
Mobile Web - Safari
output_ios.safari.mp4
Desktop
output_desktop.mp4
iOS
output_ios.mp4
Android
trimmed_output_android.mp4