Issue #312 home page scroll position on back navigation #331
No reviewers
Labels
No labels
accessibility
app-parity
area: creator
area: daemon
area: design
area: devops
area: discovery
area: docs
area: installer
area: internal
area: livestream
area: performance
area: proposal
area: reposts
area: rewards
area: search
area: security
area: subscriptions
area: sync
area: ux
area: viewer
area: wallet
BEAMER
channel
comments
community PR
consider soon
core team
css
dependencies
electron
Epic
feature request
first-timers-only
good first issue
hacktoberfest
help wanted
hub-dependent
icebox
Invalid
level: 0
level: 1
level: 2
level: 3
level: 4
merge when green
needs: exploration
needs: grooming
needs: priority
needs: repro
needs: tech design
notifications
odysee
on hold
playlists
priority: blocker
priority: high
priority: low
priority: medium
protocol dependent
recsys
redesign
regression
resilience
sdk dependent
Tom's Wishlist
trending
type: bug
type: discussion
type: improvement
type: new feature
type: refactor
type: task
type: testing
unplanned
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: LBRYCommunity/lbry-desktop#331
Loading…
Reference in a new issue
No description provided.
Delete branch "issue312"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This was a bit difficult to figure out, since
componentDidMount
is meant to execute afterrender
(based on what I have read about the React component life cycle), but for some reason, callingwindow.scrollTo
directly in this method did not work. I also tried in thecomponentDidUpdate
method. I ended up using asetTimeout
to call thescrollTo
method for the page to actually scroll to the previous position.@akinwale Is there any way to use Chrome's native scroll position retention? I suspect not, since we're controlling navigation, but perhaps it's possible.
Additionally, I'm considering whether or not we want this on all pages. I think most users would expect "back" to take them to the position they were previously in (I understand the ticket didn't stipulate this.)
Finally, I'd like to avoid using the session for this in favor of the redux store.
@akinwale want to come back to this one? I thought about merging as-is, but at a minimum it needs to only happen on "back" events, not all navigations to Discover.
@kauffj I haven't yet figured out how to detect navigation back events in React, but I've made changes to make use of the Redux store. I'll push a new commit after I'm done.
@akinwale look at
doHistoryBack
inui/actions/app.js
@kauffj Pushed a new commit.
@ -65,2 +65,4 @@
history.back();
dispatch({
type: types.HISTORY_BACK,
Is this supposed to be
HISTORY_BACK_COMPLETED
? If not, I don't thinkdoHistoryBackCompleted
ever happens. If so, I don't think we're guaranteed the render happens whilenavigatingBack
is true.The other relevant code to know here (if you haven't discovered it already) is the popstate event listener in
ui/js/main.js
. This is what history.back() is triggering.@ -40,0 +57,4 @@
}
handleScroll() {
lbry.setClientSetting("prefs_scrolly", window.scrollY);
@kauffj This delegates to
doHistoryBackCompleted()
. I called it at this point because thepopstate
event was not being fired after clicking the back button. Also,HISTORY_BACK
occurs beforeCHANGE_PATH
, and this happens beforecomponentDidMount
. I needed a way to reliably detect that the user navigated using the back button and being able to check the flag when the component mounts was how I could do it (although I figure there might be a better way but I'm not seeing it at this point).I think this can be simplified. We should be able to monitor the scroll position globally from the app component right? All back events are handled by
ui/js/main.js
. In there we can just pass ascroll
variable to thedoChangePath
action to tell it whether to scroll to a previous position or not.In fact actually we should just be able to store the scroll position in the history state and scroll ourselves, on all pages.
@6ea86b96 seems like a easier and better way to do it, any downsides?
@filipnyquist @kauffj I don't see any immediate downsides. I've implemented it here https://github.com/lbryio/lbry-app/pull/365
Now scrollY is retained over the full history.