You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[C+ Checklist Needs Completion] [$250] The focused background isn't updated when the selected option is updated from BE side #54089
Version Number: 9.0.75-6 Reproducible in staging?: Y Reproducible in production?: Y If this was caught on HybridApp, is this reproducible on New Expensify Standalone?: If this was caught during regression testing, add the test name, ID and link from TestRail: Email or phone of affected tester (no customers): Logs:https://stackoverflow.com/c/expensify/questions/4856 Expensify/Expensify Issue URL: Issue reported by:@DylanDylann Slack conversation (hyperlinked to channel name): expensify_bugs
Action Performed:
In the device 1, go to Settings> Preferences > Priority mode
In the device 2, go to Settings> Preferences > Priority mode
In the device 2, click on another option
Expected Result:
The selected option is updated in the device 1 but the focus background isn't updated
Actual Result:
The focused background isn't updated in the device 1
Workaround:
Unknown
Platforms:
Which of our officially supported platforms is this issue occurring on?
Android: Standalone
Android: HybridApp
Android: mWeb Chrome
iOS: Standalone
iOS: HybridApp
iOS: mWeb Safari
MacOS: Chrome / Safari
MacOS: Desktop
Screenshots/Videos
Add any screenshot/video evidenceScreen.Recording.2024-12-12.at.11.29.54.movRecording.844.mp4
Please re-state the problem that we are trying to solve in this issue.
The focused background isn't updated when the selected option is updated from BE side
What is the root cause of that problem?
The focus is not updated when the selected priority mode changes, causing the UI to stay focused on the old selection.
What changes do you think we should make in order to solve the problem?
We should manage the focus using a state variable (focusedKey) that gets updated when the priorityMode changes. This ensures the UI focus stays in sync with the selected priority mode.
Edited by proposal-police: This proposal was edited at 2024-12-13 02:47:13 UTC.
Proposal
Please re-state the problem that we are trying to solve in this issue.
The focused background isn't updated when the selected option is updated from BE side
What is the root cause of that problem?
In BaseSelectionList, the getItemBackgroundColorStyle function is used to get the background color for an item. This function only applies a background color if isFocused is true. When updates are received from the backend, only the isSelected state of priorityModes is updated, but isFocused is not. As a result, the focused background does not change.
What changes do you think we should make in order to solve the problem?
Out dated
In PreferencesPage, we should use a useEffect with priorityModes as a dependency to determine the focusedIndex and then call ref.current.setFocusedIndex(focusedIndex).
In the BaseSelectionList add a new prop shouldAutoUpdateFocusedIndex, with a default value of false. This prop will be set to true only in the specific places where the focused index needs to be updated automatically, in order to avoid regression.
Use useEffect with flattenedSections as a dependency to update focusedIndex
What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?
Edited at 2024-12-14 04:46:13 UTC.
I don't see any test files for this, so I think we need to implement UI tests for the BaseSelectionList component, including the following actions: render the BaseSelectionList with the correct selected status, handling item press, and rerender the BaseSelectionList with the updated selected status.
N/A
What alternative solutions did you explore? (Optional)
it('should update focused item when sections are updated from BE',()=>{constupdatedSections=SECTIONS.map((section)=>({
...section,isSelected: section.keyForList==='2',}));const{rerender}=render(<RenderBaseSelectionListsections={[{data: SECTIONS}]}/>);fireEvent.press(screen.getByTestId('base-list-item-1'));rerender(<RenderBaseSelectionListsections={[{data: updatedSections}]}/>);expect(screen.getByTestId('base-list-item-2')).toHaveAccessibilityValue({selected: true,});});
Optionally, we can test for keyboard control as well, but this test will require to install an additional package @testing-library/user-event:
What alternative solutions did you explore? (Optional)
We can pass key to SelectionList in PriorityModePage to force re-render when priority mode is changed, however this can cause unwanted extra render count and make the UI briefly flashes but still noticeable.
changed the title [-]The focused background isn't updated when the selected option is updated from BE side[/-][+][$250] The focused background isn't updated when the selected option is updated from BE side[/+]on Dec 13, 2024
@DylanDylann@michaelkwardrop@DylanDylann The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]
changed the title [-][HOLD for payment 2025-01-17] [$250] The focused background isn't updated when the selected option is updated from BE side[/-][+][C+ Checklist Needs Completion] [$250] The focused background isn't updated when the selected option is updated from BE side[/+]on Jan 17, 2025
1a. Result of the original design (eg. a case wasn't considered)
1b. Mistake during implementation
1c. Backend bug
1z. Other:
Where bug was reported:
2a. Reported on production (eg. bug slipped through the normal regression and PR testing process on staging)
2b. Reported on staging (eg. found during regression or PR testing)
2d. Reported on a PR
2z. Other:
Who reported the bug:
3a. Expensify user
3b. Expensify employee
3c. Contributor
3d. QA
3z. Other:
[Contributor] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake.
Link to comment: No. This is a new improvement, not a bug
[Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner.
Link to discussion:
[Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.
[BugZero Assignee] Create a GH issue for creating/updating the regression test once above steps have been agreed upon.
Link to issue:
Regression Test Proposal
Test:
In the device 1, go to Settings > Preferences > Priority mode
In the device 2, go to Settings > Preferences > Priority mode
In the device 2, click on another option
Verify that: In device 1, selected option is updated and focused background is displayed correctly.
Activity
melvin-bot commentedon Dec 13, 2024
Triggered auto assignment to @michaelkwardrop (
Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.nyomanjyotisa commentedon Dec 13, 2024
Proposal
Please re-state the problem that we are trying to solve in this issue.
The focused background isn't updated when the selected option is updated from BE side
What is the root cause of that problem?
The focus is not updated when the selected priority mode changes, causing the UI to stay focused on the old selection.
What changes do you think we should make in order to solve the problem?
We should manage the focus using a state variable (
focusedKey) that gets updated when thepriorityModechanges. This ensures the UI focus stays in sync with the selected priority mode.And change the
SelectionListto thisWhat specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?
What alternative solutions did you explore? (Optional)
POC
New-Expensify.mp4
linhvovan29546 commentedon Dec 13, 2024
Edited by proposal-police: This proposal was edited at 2024-12-13 02:47:13 UTC.
Proposal
Please re-state the problem that we are trying to solve in this issue.
The focused background isn't updated when the selected option is updated from BE side
What is the root cause of that problem?
In BaseSelectionList, the
getItemBackgroundColorStylefunction is used to get the background color for an item. This function only applies a background color ifisFocusedis true. When updates are received from the backend, only theisSelectedstate ofpriorityModesis updated, butisFocusedis not. As a result, the focused background does not change.App/src/components/SelectionList/BaseListItem.tsx
Line 113 in 10bfe9a
What changes do you think we should make in order to solve the problem?
Out dated
In PreferencesPage, we should use a
useEffectwithpriorityModesas a dependency to determine thefocusedIndexand then callref.current.setFocusedIndex(focusedIndex).We also need to export the
setFocusedIndexmethod fromBaseSelectionListusinguseImperativeHandleto enable this functionality.App/src/components/SelectionList/BaseSelectionList.tsx
Lines 735 to 741 in 10bfe9a
New proposal:
In the BaseSelectionList add a new prop
shouldAutoUpdateFocusedIndex, with a default value offalse. This prop will be set totrueonly in the specific places where the focused index needs to be updated automatically, in order to avoid regression.Use
useEffectwithflattenedSectionsas a dependency to update focusedIndexWhat specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?
Edited at 2024-12-14 04:46:13 UTC.
I don't see any test files for this, so I think we need to implement UI tests for the
BaseSelectionListcomponent, including the following actions: render theBaseSelectionListwith the correct selected status, handling item press, and rerender theBaseSelectionListwith the updated selected status.N/A
What alternative solutions did you explore? (Optional)
N/A
daledah commentedon Dec 13, 2024
Edited by proposal-police: This proposal was edited at 2024-12-19 16:20:50 UTC.
Proposal
Please re-state the problem that we are trying to solve in this issue.
The focused background isn't updated in the device 1
What is the root cause of that problem?
In
BaseSelectionList, we don't have logics to changefocusedIndexwhen there's update from BE.This Bug also appears on similar pages: Language and Theme settings.
What changes do you think we should make in order to solve the problem?
Add an
useEffectto changefocusedIndexwhen list data is updated to after here:App/src/components/SelectionList/BaseSelectionList.tsx
Line 337 in 10bfe9a
What specific scenarios should we cover in automated tests to prevent reintroducing this issue in the future?
For this specific issue, we can introduce these test cases for
BaseSelectionList:@testing-library/user-event:What alternative solutions did you explore? (Optional)
We can pass
keytoSelectionListinPriorityModePageto force re-render when priority mode is changed, however this can cause unwanted extra render count and make the UI briefly flashes but still noticeable.DylanDylann commentedon Dec 13, 2024
hey contributors, please make sure that your proposal also fix this problem
DylanDylann commentedon Dec 13, 2024
@michaelkwardrop Let me take over this bug because it came from https://expensify.slack.com/archives/C05LX9D6E07/p1733996291225739?thread_ts=1730403194.757359&cid=C05LX9D6E07
cc @mountiny @joekaufmanexpensify
linhvovan29546 commentedon Dec 13, 2024
Updated proposal to fix this problem
#54089 (comment)
melvin-bot commentedon Dec 13, 2024
Job added to Upwork: https://www.upwork.com/jobs/~021867633562881780913
[-]The focused background isn't updated when the selected option is updated from BE side[/-][+][$250] The focused background isn't updated when the selected option is updated from BE side[/+]32 remaining items
melvin-bot commentedon Jan 10, 2025
@DylanDylann @michaelkwardrop @DylanDylann The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button]
srikarparsi commentedon Jan 13, 2025
Hi @daledah and @DylanDylann, do you think you could take a look at this regression please which seems to come from this PR?
DylanDylann commentedon Jan 13, 2025
@srikarparsi Yes it is a regression from our prev PR. @daledah Let's create a PR to fix it, I believe that the fix is small
michaelkwardrop commentedon Jan 17, 2025
Payment summary:
Contributor: @daledah $125 - paid via UpWork ✅
C+: @DylanDylann $125 - paying via UpWork (once checklist is completed)
50% regression penalty #54931
[-][HOLD for payment 2025-01-17] [$250] The focused background isn't updated when the selected option is updated from BE side[/-][+][C+ Checklist Needs Completion] [$250] The focused background isn't updated when the selected option is updated from BE side[/+]DylanDylann commentedon Jan 20, 2025
BugZero Checklist:
Bug classification
Source of bug:
Where bug was reported:
Who reported the bug:
[Contributor] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake.
Link to comment: No. This is a new improvement, not a bug
[Contributor] If the regression was CRITICAL (e.g. interrupts a core flow) A discussion in #expensify-open-source has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner.
Link to discussion:
[Contributor] If it was decided to create a regression test for the bug, please propose the regression test steps using the template below to ensure the same bug will not reach production again.
[BugZero Assignee] Create a GH issue for creating/updating the regression test once above steps have been agreed upon.
Link to issue:
Regression Test Proposal
Test:
Do we agree 👍 or 👎
michaelkwardrop commentedon Jan 23, 2025
https://github.com/Expensify/Expensify/issues/463844
michaelkwardrop commentedon Jan 23, 2025
UPDATE
Payment summary:
Contributor: @daledah $125 - paid via UpWork ✅
C+: @DylanDylann $125 - paid via UpWork ✅
50% regression penalty #54931
michaelkwardrop commentedon Jan 23, 2025
Job has been closed in Upwork, closing this out. Great work.