-
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
The central page page is not rendered when resized to narrow and then to wide view again #53466
The central page page is not rendered when resized to narrow and then to wide view again #53466
Conversation
Makes sense to me |
Reviewer Checklist
Screenshots/VideosAndroid: Native53466-android-native.mp4Android: mWeb Chrome53466-android-web.mp4iOS: Native53466-ios-native.mp4iOS: mWeb Safari53466-ios-safari.mp4MacOS: Chrome / Safari53466-mac-chrome.mp4MacOS: Desktop53466-mac-desktop.mp4 |
@ntdiary kicked off a build |
🚧 @mountiny has triggered a test build. You can view the workflow run here. |
🧪🧪 Use the links below to test this adhoc build on Android, iOS, Desktop, and Web. Happy testing! 🧪🧪 |
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.
LGTM. The original change was made to resolve the reload problem, and it is working fine 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.
Is there any way for us to add a unit test or UI test for this?
import useResponsiveLayout from '@hooks/useResponsiveLayout'; | ||
import navigationRef from '@libs/Navigation/navigationRef'; | ||
|
||
function useNavigationResetRootOnLayoutChange() { |
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.
Can we add a comment description of what this is used for.
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.
Would be good to start setting this up for more unit tests in the navigation are too @WojtekBoman @adamgrzybowski
@adamgrzybowski @WojtekBoman What do you think about the tests, can you add some now? what is your ETA if so? thanks! |
@mountiny, @WojtekBoman is working on tests but he was on sick leave today 🦷 We looked into the We may need to create some generic utils for future tests. This specific case above may be a little problematic. We should test resizing. For testing, we use the react-native testing library and there is no resizing on the native version of Expensify 😄. We have some ideas though. We will get back to you on Monday. |
I'm still working on tests for that issue. I've already prepared some and they seem to work, however I'm still investigating how to cleanly mock functions and components that I'm testing |
@mountiny @puneetlath @ntdiary @adamgrzybowski Tests are ready 🫡 |
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.
Great! Thank you very much! @ntdiary can you also check out the code please
const mockedUseResponsiveLayout = useResponsiveLayout as jest.MockedFunction<typeof useResponsiveLayout>; | ||
|
||
describe('Resize screen', () => { | ||
it('Should display the settings profile after resizing the screen with the settings page opened to the wide layout', () => { |
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.
A great test case! As described, it ensures that when resizing the screen on the /settings
page, useNavigationResetRootOnLayoutChange
takes effect, and getAdaptedState
pushes profile
into the routes and then renders it (i.e., /settings/profile
).
App/src/libs/Navigation/linkingConfig/getAdaptedStateFromPath.ts
Lines 365 to 367 in f9ec4fa
const matchingCentralPaneRoute = getMatchingCentralPaneRouteForState(state); | |
if (matchingCentralPaneRoute) { | |
routes.push(matchingCentralPaneRoute); |
As for the /settings/workspaces/xxx
and /settings/workspaces/xxx/profile
pages, their route switching happens here:
App/src/libs/Navigation/AppNavigator/createCustomFullScreenNavigator/CustomFullScreenRouter.tsx
Lines 51 to 54 in f9ec4fa
// If the screen is wide, there should be at least two screens inside: | |
// - WORKSPACE.INITIAL to cover left pane. | |
// - WORKSPACE.PROFILE (first workspace settings screen) to cover central pane. | |
if (!isNarrowLayout) { |
If needed, maybe similar test case could be added for them as well? I’m not a test expert, so not entirely sure. :)
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.
Yes, it's a good point :) We're going to add this test in our PR including nav refactor as it contains many changes related to this code. I believe we can go ahead with this PR for 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.
Same, I think we can keep on adding more test cases in future, but its good for this PR
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
🚀 Deployed to staging by https://github.com/mountiny in version: 9.0.75-0 🚀
|
🚀 Deployed to production by https://github.com/luacmartins in version: 9.0.75-6 🚀
|
Explanation of Change
useNavigationResetOnLayoutChange
was modified to reset navigation state using theresetRoot
method. Due to this change, theFullScreenNavigator
state could not be reset because this navigator is nested inrootState
. This PR introducesuseNavigationResetRootOnLayoutChange
and restoresuseNavigationResetOnLayoutChange
as it was previously implemented to fix resettingFullScreenNavigator
.Fixed Issues
$ #53445
$ #53395
PROPOSAL:
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
)src/languages/*
files and using the translation methodSTYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)Design
label and/or tagged@Expensify/design
so the design team can review the changes.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
MacOS: Chrome / Safari
Screen.Recording.2024-12-03.at.15.36.47.mov
MacOS: Desktop
Screen.Recording.2024-12-03.at.15.21.46.mp4