-
Notifications
You must be signed in to change notification settings - Fork 3.2k
migrate AccountType step to FormProvider #56464
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
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
01c4db1
migrate AccountType step to FormProvider
mkzie2 8de5987
Merge branch 'main' into mkzie2-issue/55688
mkzie2 3340c4e
remove the extra step for account type step
mkzie2 99e2c6d
Merge branch 'main' into mkzie2-issue/55688
mkzie2 8d64c55
update focused key
mkzie2 669b4d1
Merge branch 'main' into mkzie2-issue/55688
mkzie2 3239142
Merge branch 'main' into mkzie2-issue/55688
mkzie2 59863a2
merge main
mkzie2 72ab9e2
Merge branch 'main' into mkzie2-issue/55688
mkzie2 9ca4629
remove confirm button when editing the account type step
mkzie2 d8a5519
Merge branch 'mkzie2-issue/55688' of https://github.com/mkzie2/App in…
mkzie2 9c50026
add return type
mkzie2 dbcfd16
Merge branch 'main' of https://github.com/mkzie2/App into mkzie2-issu…
mkzie2 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 hidden or 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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import React, {useMemo} from 'react'; | ||
import SelectionList from '@components/SelectionList'; | ||
import RadioListItem from '@components/SelectionList/RadioListItem'; | ||
import type {ValueSelectionListProps} from './types'; | ||
|
||
function ValueSelectionList({items = [], selectedItem, onItemSelected, shouldShowTooltips = true}: ValueSelectionListProps) { | ||
const sections = useMemo( | ||
() => [{data: items.map((item) => ({value: item.value, alternateText: item.description, text: item.label ?? '', isSelected: item === selectedItem, keyForList: item.value ?? ''}))}], | ||
[items, selectedItem], | ||
); | ||
|
||
return ( | ||
<SelectionList | ||
sections={sections} | ||
onSelectRow={(item) => onItemSelected?.(item)} | ||
initiallyFocusedOptionKey={selectedItem?.value} | ||
shouldStopPropagation | ||
shouldShowTooltips={shouldShowTooltips} | ||
shouldUpdateFocusedIndex | ||
ListItem={RadioListItem} | ||
/> | ||
); | ||
} | ||
|
||
ValueSelectionList.displayName = 'ValueSelectionList'; | ||
|
||
export default ValueSelectionList; |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
109 changes: 49 additions & 60 deletions
109
src/pages/settings/Wallet/InternationalDepositAccount/substeps/AccountType.tsx
This file contains hidden or 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
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.
Uh oh!
There was an error while loading. Please reload this page.
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.
@cead22 Thanks for your feedback, let me clarify it again.
ValuePicker
is an existing component; we can reuse this in theAccountType
step when migrating toFormProvider
.Yes, here is the result of my first implementation
Screen.Recording.2025-02-11.at.15.57.27.mov
menu item
modal
The main idea of the last implementation is creating a way to only show the selection list without the extra step of opening the modal. Then I implement it in
ValuePicker
with a new prop so we can use this in the feature if we want. And the result will be like thisAs the idea above, we only need to reuse the
SelectionList
part onValueSelectorModal
and render it inValuePicker
ifshouldShowModal
props isfalse
You can see here
ValueSelectionList
used theSelectionList
. The purpose of this component is prevent the duplicate code when I add bothSelectionList
inValuePicker
andValueSelectorModal
.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.
@cead22 Any thoughts on my comment above.
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.
Sorry for the delay, it's been a busy few days.
To clarify, are there alternative ways to implement this? If so, can you share why they're not as good as this one? If there aren't, can you explain why?
Sorry if this is all known to others, but I'm not super well versed on all the components that exists and how they work together
Just to make sure I understand, the selection list looks very similar to the modal, and the main difference is that the modal has a green button you need to click after making the selection?
Again just so I learn, if we didn't want to do this in anticipation of using it in the future, how would the code be different? Not saying we should change it, I just want to understand exactly what's needed for now, vs what we're doing to set this up to be re-used
I didn't quite follow this. Can we use SelectionList in ValuePicker? Does that question make sense?
👍 thanks, I get this now
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.
@cead22
We can create a new component and use it as
InputWrapper
of theFormProvider
in theAccountType
step. But we're good to use theValuePicker
because we can see theSelectionList
insideAccountType
(the code on the latest main) is the same with the selection list insideValueSelectorModal
ofValuePicker
App/src/pages/settings/Wallet/InternationalDepositAccount/substeps/AccountType.tsx
Lines 81 to 90 in c23850d
The main idea is to keep the current UI and behavior in the
AccountType
step, but usingFormProvier
withValuePicker
instead of the current code here. And then when using theValuePicker
, we need a way only to display theSelectionList
, then the behavior is the same as we have on the main, making a selection and clicking on the confirm button to go to the next step.App/src/pages/settings/Wallet/InternationalDepositAccount/substeps/AccountType.tsx
Lines 81 to 90 in c23850d
In the feature, if we have a substep with a single field and we need to make a selection, we can reuse the
ValuePicker
withshouldShowModal
asfalse
to remove the extra step.InputWrapper
component that is only a selection list like the current selection in here. And becauseValuePicker
already had the same list like this, we can use this component with introducing a new prop to simply return the selection list if this prop isfalse
App/src/pages/settings/Wallet/InternationalDepositAccount/substeps/AccountType.tsx
Lines 81 to 90 in c23850d
shouldShowModal
. If we have a substep that has the same UI and behavior like thisAccountType
step, we can re-use like 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.
Sorry, I still don't understand this. When I asked about whether there's another way, I meant with existing logic/components. I don't think this addresses why the current solution is better (apologies if it does)
Sorry about this one too, but I'm not sure if/how this answers my question. What does "the extra step of opening the modal" mean in "The main idea of the last implementation is creating a way to only show the selection list without the extra step of opening the modal."?
Thanks for this explanation. Is this something we anticipate using right away, or should we add it when we need it?
I'm gonna find a better reviewer for this PR. I don't want to keep delaying it, but I also don't want to merge code I don't understand