-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
[Wave 8] [Ideal Nav] Save scroll position on HOME screen #38161
[Wave 8] [Ideal Nav] Save scroll position on HOME screen #38161
Conversation
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.
If I am not missing anything, the entire solution is not necessary for native as they're never unmounted before logout, right?
Why can't we prevent unmount LHN when switch to other pages? |
@situchan Not sure about unmounting but there is still the second problem. On native if we switch tabs like HOME -> SETTINGS -> HOME, then the visible home screen is a different component than the first one. That's because we use the stack navigator underneath even for the bottom tab. That means the scroll position from the first visit wouldn't persist on the second visit to this tab The video below shows how it currently works on the main. You can compare it with the ios native video included for this PR @situchan Not sure about unmounting but there is still the second problem. On native if we switch tabs like HOME -> SETTINGS -> HOME, then the second home component is actually a different component from the Screen.Recording.2024-03-13.at.15.57.10.mov |
Is it impossible to fix this? |
|
ok so this is inevitable for web. I might be wrong but should we also keep Settings tab (now Profile tab for ideal nav v2) scroll position for consistency? |
When implementing the bottom tab navigator we decided to use a stack that pretends to be a tab navigator instead of a real bottom tab. Our motivation was the fact that the history in the browser seemed to be broken for the tab navigator. Or at least doesn't support the pattern that we wanted to implement. Additionally, the stack navigator is more flexible which allowed us to implement some features without unnecessary nested navigators (I think this may be no longer needed with ideal-nav-v2) In theory, we could go back, try to fix the react-navigation bottom tab history upstream, and switch the current implementation of the bottom tab for the real bottom tab but personally I don't see any reason to do that.
Agree with this one. I see that the v2 was merged yesterday. In that case I can modify this PR to cover the settings scroll |
ok let me know when it's done |
@situchan Done! |
Conflicts! |
@situchan bump |
Reviewer Checklist
Screenshots/VideosAndroid: Nativeandroid.movAndroid: mWeb Chromemchrome.moviOS: Nativeios.moviOS: mWeb Safarimsafari.movMacOS: Chrome / Safariweb.movMacOS: Desktopdesktop.mov |
Hey, @situchan It looks like this PR is ok to merge. Do you know who to ask for that? |
I didn't approve yet. Will do shortly |
@adamgrzybowski please fix conflict |
@situchan resolved |
@situchan what is your eta on this one please? |
eod |
Should this be considered out of scope? There's glitch when lots of data in LHN: Screen.Recording.2024-03-21.at.7.51.27.AM.mov |
This is polish but when switch focus mode, I think it's better to reset scroll position to top Screen.Recording.2024-03-21.at.7.56.08.AM.mov |
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.
Looks good, considering above concerns are non blockers
I think I saw something like this even without this PR. Not sure if we can do something about it here.
This is very good point. Let me fix that |
@situchan okay, changing priority should now reset saved scrolls for home |
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.
🟢
const previousPriorityMode = useRef<PriorityMode>(priorityMode); | ||
|
||
useEffect(() => { | ||
if (previousPriorityMode.current === priorityMode) { |
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.
We can use usePrevious
hook to compare with prev props value.
Btw, is this reasonable approach to reset scroll of HOME screen here? This is general context provider.
I thought of handling in LHNOptionsList
.
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.
I feel like having this in one place rather than scattering it in different files makes it easier to understand. But I am open to hear different opinions.
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.
ok, I am fine with current approach.
Please merge main. Perf tests failing |
@situchan done |
@adamgrzybowski it's not fixed yet Screen.Recording.2024-03-22.at.6.54.58.PM.mov |
@situchan okay now it should work for the case with two apps opened |
🟢 |
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.
🟢
Details
Problem
There were two reasons why the scroll is reset when switching tabs / going back in history.
Solution
To make sure the scroll position is persistent when we navigate between tabs there is a new
ScrollOffsetContext
used to save the value. When the user navigates to the HOME tab we check if there is a scroll offset saved for this particular screen with given policyID. If yes we can use it to set the offset.Note
After some modifications this solution could be used to save the conversation scroll position if this is something we want to implement.
Solution I tried
In theory if we have situation where we navigate HOME -> SETTINGS -> HOME we could try to reuse the first HOME component to render the second HOME if both have the same policyID.
On the web for some reason after this operation the scroll position is lost anyway. Even if we force the HOME screen to stay displayed under other tabs.
On the mobile it completely breaks the screen rendering.
However, reusing screens may slightly improve performance when opening the HOME tab on the web. Perhaps this is something to investigate in the future.
Fixed Issues
$ #35602
PROPOSAL:
Tests
Offline tests
QA Steps
extra steps for platforms with go back possible
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.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
Android: Native
androidNative.mov
Android: mWeb Chrome
androidWeb.mov
iOS: Native
iosNative.mov
iOS: mWeb Safari
iosWeb.mov
MacOS: Chrome / Safari
web.mov
MacOS: Desktop
desktop.mov