Repository navigation
[No QA] Document pinning the pre-selected item in searchable lists - #104714
marufsharifi wants to merge 3 commits into
Conversation
|
@linhvovan29546 @robertjchen One of you needs to 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] |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 67bf40d331
ℹ️ About Codex in GitHub
Your team has set up Codex to 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 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
| Flag ONLY when ALL of these are true: | ||
|
|
||
| - The changed code adds or changes a `SelectionList` / `SelectionScreen` that shows a search input (`textInputOptions` or `shouldShowTextInput`) |
There was a problem hiding this comment.
Include SelectionListWithSections in the rule scope
When a changed picker renders SelectionListWithSections directly, this required condition does not match even though the sectioned component exposes the same search and selection APIs; for example, src/components/CurrencySelectionList/index.tsx:110-119 renders a searchable, pre-selected sectioned list. Because the reviewer is told to flag only when all conditions hold, regressions in these pickers will be skipped, so include SelectionListWithSections in this condition and its search patterns.
Useful? React with 👍 / 👎.
|
|
||
| ```tsx | ||
| // Freeze the selection on open so later taps don't reorder the list, then pin it to the top before filtering. | ||
| const initialSelectedValue = useInitialValue(() => selectedValue); |
There was a problem hiding this comment.
Handle late-loaded selections in the correct example
When the saved selection arrives asynchronously after mount, such as from an Onyx-backed picker, this captures undefined permanently because src/hooks/useInitialValue.ts:6-8 never updates it, so the eventual selected row remains unpinned. useSelectionListSearch explicitly waits for the first render with data at src/hooks/useSelectionListSearch.ts:19-24; the canonical example should likewise use a loading-aware snapshot (or state that it is only valid once the selection is loaded), otherwise reviewers can approve this broken pattern as “Correct.”
Useful? React with 👍 / 👎.
| - Snapshot the selected value when the list opens (for example with `useInitialValue`) so a later tap does not reorder the list mid-interaction. | ||
| - Pin it to the top of the full list **before** filtering with `moveInitialSelectionToTop` (from `@libs/SelectionListOrderUtils`). It no-ops for lists below `CONST.STANDARD_LIST_ITEM_LIMIT`, so short lists keep their natural order. | ||
| - Any clear/"None" row belongs directly **below** the pinned selection. | ||
| - Pages built on `SelectionScreen` get this automatically from `useSelectionListSearch`, which pins the frozen selection and returns `pinnedValues` for callers that need to know what was pinned. |
There was a problem hiding this comment.
Require SelectionScreen callers to invoke the search hook
When a new caller passes raw searchable data to SelectionScreen, pinning is not automatic: src/components/SelectionScreen.tsx:175-182 forwards data directly and never invokes useSelectionListSearch. This guidance can therefore cause callers to omit the ordering step and leave the saved row buried; state that callers must run the hook and pass its filteredData (or move the hook into the wrapper) rather than claiming SelectionScreen provides it automatically.
Useful? React with 👍 / 👎.
Julesssss
left a comment
There was a problem hiding this comment.
I don't think we should be creating a specific rule just for this specific case. We don't want to bloat them and reduce code review quality.
We could keep the contributing guide though, happy to merge just that docs update.
|
@Julesssss Updated the changes, could you take a look when you get a chance ? thanks |
Reviewer Checklist
Screenshots/VideosAndroid: HybridAppAndroid: mWeb ChromeiOS: HybridAppiOS: mWeb SafariMacOS: Chrome / Safari |
|
Claude posting on behalf of Matt: Closing this PR. Work on the linked issue continues in a new PR. Use this one as a reference. |
Explanation of Change
Follow-up to #69184. That effort moved pre-selected items to the top of every existing searchable list in the app. This PR adds a review rule so new or changed lists keep doing it.
This is a documentation / review-tooling change only — no application code is touched.
Fixed Issues
$ #69184
PROPOSAL:
Tests
N/A
Offline tests
N/A
QA Steps
N/A
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectionAvatar, I verified the components usingAvatarare working as expected)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.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: mWeb Safari
MacOS: Chrome / Safari