Migrate TypeSelectorModal to react-navigation#91102
Conversation
|
Hey! I see that you made changes to our Form component. Make sure to update the docs in FORMS.md accordingly. Cheers! |
Codecov Report❌ Looks like you've decreased code coverage for some files. Please write tests to increase, or at least maintain, the existing level of code coverage. See our documentation here for how to interpret this table.
|
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6c1b37c0e8
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| [INPUT_IDS.TYPE]: item.value, | ||
| [INPUT_IDS.INITIAL_VALUE]: getDefaultInitialValueForReportFieldType(item.value), | ||
| }); | ||
| Navigation.goBack(); |
There was a problem hiding this comment.
Use a fallback route when exiting type selector
Navigating away with plain Navigation.goBack() can fail when this screen is opened directly (deeplink/web reload) because there may be no back stack entry; Navigation.goBack logs and returns when canGoBack() is false. In that case, selecting a type leaves users stuck on this page even after writing draft values. Please pass an explicit fallback route (for this flow, the report-field create route) when going back from selection.
Useful? React with 👍 / 👎.
|
@codex review |
|
Codex Review: Didn't find any major issues. Nice work! ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
|
@ZhenjaHorbach 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] |
|
PR doesn’t need product input as a refactor PR. Unassigning and unsubscribing myself. |
| ); | ||
| } | ||
|
|
||
| TypeSelectorPage.displayName = 'TypeSelectorPage'; |
There was a problem hiding this comment.
As remember, we don't use displayName anymore
| * Designed to live inside `FormProvider`'s render prop so consumers can react to draft-driven updates | ||
| * (e.g. from an RHP picker page) without having to wire up their own previous-value ref + effect. | ||
| */ | ||
| function FormValueWatcher<TFormID extends OnyxFormKey>({values, onValuesChange}: FormValueWatcherProps<TFormID>) { |
There was a problem hiding this comment.
Should we add this logic inside FormProvider?
There was a problem hiding this comment.
@ZhenjaHorbach I don't think so. I separated it out into a component because FormProvider has more than 500 references across the codebase. And I was the only consumer. I wanted to be more modular and have something I could use, but also something that could be used by others if there's a need for it.
There was a problem hiding this comment.
the useEffect would run on every change of values for those 100+ consumers that don't use it.
There was a problem hiding this comment.
Okay then
I'm just a little confused by render-null component and how it is used
But on the other hand, there seems to be no better solution in the current situation
So let's leave it as is 😁
|
@ZhenjaHorbach fixed the issue you mentioned |
|
Looks like we don't reset a type after closing Add field modal 2026-05-22.10.21.10.mov |
Explanation of Change
Migrates
TypeSelectorModal(react-native-modal) to a@react-navigationRHP screen (TypeSelectorPage) for consistent right-to-left animations.TypeSelectoris now aMenuItemWithTopDescriptionthat navigates to the new screen; selection writestype+ computedinitialValueto the form draft. A newFormValueWatcherprimitive preserves the originalresetFormsemantics (clears errors /touchedflags) without leaking effects intoFormProvider.Fixed Issues
$ #90473
PROPOSAL:
Tests
{report:id}for Formula, hidden (and replaced by the List values row) for List.resetFormviaFormValueWatcher).{report:total}on the sub-screen and tap Save to return. The form auto-switches Type to Formula (existing behavior ofhandleOnValueCommitted). Re-open the Type picker and verify it highlights Formula (the live type), not the previous Text.Offline tests
Same as tests.
QA Steps
Same as tests.
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))npm run compress-svg)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.mp4
iOS: mWeb Safari
MacOS: Chrome / Safari