Skip to content
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

scroller: invert list based on reading direction #3236

Merged
merged 10 commits into from
Feb 22, 2024

Conversation

patosullivan
Copy link
Member

@patosullivan patosullivan commented Feb 12, 2024

Fixes LAND-1353.

This changes our logic about whether or not to invert the list. Rather than relying on load direction, we make the invert/uninvert decision base on reading direction (whether the user perceives to be scrolling up or down). If scrolling up, we invert. If scrolling down, we "uninvert". This avoids jumpiness associated with scrolling "up" in an uninverted state, or "down" in an inverted state (see TanStack/virtual#659). We also assume that if a user has scrolled directly to a message they are going to begin reading "down" from that message.

This also moves a few variables around for easier readability, and moves a few variables into useMemo where it seems appropriate.

Tested on local dev moons on livenet.

PR Checklist

  • Includes changes to desk files
  • Describes how you tested the PR locally (test ship vs livenet)
  • If a new feature, includes automated tests
  • Comments added anywhere logic may be confusing without context

Fixes LAND-1353.

This changes our logic about whether or not to invert the list. Rather than relying on load direction, we make the invert/uninvert decision base on reading direction (whether the user perceives to be scrolling up or down). If scrolling up, we invert. If scrolling down, we "uninvert". This avoids jumpiness associated with scrolling "up" in an uninverted state, or "down" in an inverted state.

This also moves a few variables around for easier readability, and moves a few variables into useMemo where it seems appropriate.
Copy link

linear bot commented Feb 12, 2024

@patosullivan
Copy link
Member Author

Moving to draft while I diagnose a bug when exiting/re-opening thread pane.

@mrozanski
Copy link
Contributor

There is a jump I get consistently when a thread view is closed. The scroll position in the main conversation jumps to an older point, presumably the oldest that was fetched so far.
(We reviewed this on a call, just adding here to ensure we test that before merging)

@patosullivan patosullivan marked this pull request as draft February 12, 2024 21:15
@mrozanski
Copy link
Contributor

I detected something that may be related to the thread open/close issue, or at least has a similar result.

On desktop,
If I open a chat with unreads,
click on the "n new messages since xyz. - Click to view"
takes me to the first new message (which - separate issue - doesn't display in a consistent position, but in one case mid screen and in another near the bottom)
Then as soon as I start scrolling to continue reading below the oldest new one, the conversation jumps way back.

…/reopening threads or clicking 'go to latest'
@patosullivan
Copy link
Member Author

Fixed the issues mariano found afaict, working on a new issue now (click to view not scrolling).

@patosullivan patosullivan marked this pull request as ready for review February 13, 2024 18:13
@patosullivan
Copy link
Member Author

patosullivan commented Feb 13, 2024

Ok, I think we're back in a state where someone other than me should try banging on this to find if there are any remaining issues.

@latter-bolden
Copy link
Member

latter-bolden commented Feb 15, 2024

@patosullivan here's a clip of the issue I was trying to describe in standup. Steps to reproduce:

  1. Be scrolled back in the history and start scrolling down (towards newer messages)
  2. Stop and initiate a scroll back up (towards older messages)

You can sometimes see oscillating behavior when the scroller is fighting your movement, other times it stays in place and doesn't move despite the trackpad input (see first & last pause in the video). Looks like the inversion is correctly updating immediately in the scroller devtools.

I think the real world case where this might occur is if you're scanning chat history quickly and you pass a message you actually want to read/focus on. Seemed to present even with a longer, more natural interval between switching directions than what's demoed.

Screen.Recording.2024-02-15.at.12.25.25.PM.mov

@patosullivan
Copy link
Member Author

I'm having a hard time reproducing the frozen state that @latter-bolden found, might need to pair to see exactly how to trigger that one.

I've been looking at how to reduce the jitter on the flip between inverted/uninverted, not coming up with much as of yet. Will keep trying.

@patosullivan
Copy link
Member Author

@latter-bolden I setup a way to throttle the change in scroll direction, which reduces the frequency that a user should see any jumpyness while we invert/un-invert, and may also fix the issue you're seeing. Let me know if you're still seeing that.

@mrozanski
Copy link
Contributor

Testing the latest locally, on desktop, I've noticed a new issue.

  1. Go to a chat channel
  2. Using the scroll wheel or equivalent gesture (with a magic mouse, that is vertical swipe with one finger)
  3. Perform a short movement (I swipe vertically the equivalent to 200-300 px or the hight of 4-5 lines of text) and let go, to allow momentum to carry the motion until it stops.
  4. Once it stops, perform the oposite scroll movement, again swiping vertically for a short distance, and let it stop
  5. One more time, now in the oposite direction, perform a short scroll movement

After two momentum / full-stop cycles in oposite directions what I observe is that the third one stops abruptly after a fraction of a second and makes two or three short jumps back and forth.

I think letting the momentum stop by itself is the trigger

Copy link
Member

@latter-bolden latter-bolden left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing glaring in the code. Let's get this merged so we can feel it out in practice

@patosullivan patosullivan merged commit 77cf0c2 into develop Feb 22, 2024
1 check passed
@patosullivan patosullivan deleted the po/land-1353-invert-list-only-when-appropriate branch February 22, 2024 22:59
patosullivan added a commit that referenced this pull request Feb 27, 2024
This reverts the changes made to invert the scroller direction based on reading direction, from #3236

Also adds more logging so we can get some more insight into what is changing and when.

Dan and I used the afternoon to try to find what was causing the issue in iOS, couldn't find anything within a reasonable amount of time.

So LAND-1353 is now unresolved.

We ought to pull in the @tanstack/virtual library to our shared packages so we can get some clearer debugging around what's happening in virtual and maybe modify to our needs.
I looked at pulling it in, but the package itself uses workspaces and pnpm, so not super straight forward to pull in directly. We should create a ticket for it IMO.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants