-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Reader: fix scroll depth tracking #98093
Conversation
Jetpack Cloud live (direct link)
Automattic for Agencies live (direct link)
|
Here is how your PR affects size of JS and CSS bundles shipped to the user's browser: Async-loaded Components (~108 bytes added 📈 [gzipped])
React components that are loaded lazily, when a certain part of UI is displayed for the first time. Legend What is parsed and gzip size?Parsed Size: Uncompressed size of the JS and CSS files. This much code needs to be parsed and stored in memory. Generated by performance advisor bot at iscalypsofastyet.com. |
This PR modifies the release build for the following Calypso Apps: For info about this notification, see here: PCYsg-OT6-p2
To test WordPress.com changes, run |
maxScrollDepth: 0, // Track the maximum scroll depth achieved | ||
hasCompleted: false, // Track whether the user completed the post |
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.
No longer need this component state because we just need to know the max scroll depth at the moment when we unmount or the post/feed changes. All of that tracking logic was moved to scroll-tracker.ts
and just uses event listeners.
this.scrollableContainer.removeEventListener( 'scroll', this.setScrollDepth ); | ||
} | ||
// Track scroll depth and remove related instruments | ||
this.trackScrollDepth( this.props.post ); |
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 need to track the scroll depth when the component is about to unmount. We were missing events when the feed would change or a new page in the middle column was requested because the component actually unmounts/remounts in those cases.
@@ -18,6 +18,7 @@ body.is-reader-full-post { | |||
); | |||
|
|||
height: $feed-content-height !important; // Using !important here to avoid having a lengthy selector. | |||
overflow-y: hidden !important; // Keeps the scrolling container consistent between one and two column layouts. |
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.
These css changes fix an issue where the scroll container changed based on the viewport width, meaning we were no longer getting events. This ensures that the same DOM element is the scrolling container in the Recent feed.
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.
meaning we were no longer getting events
I understand the motivation, but looks like this had a side-effect. In the reader recent tab, if you scroll down while reading a longish post and click on another post, the scroll position doesn't reset to the top of the post.
We fixed it here should you want to see the before and after videos, but I suspect this change makes it come back since it doesn't happen on trunk.
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.
Appears to work well, I left a comment about the CSS changes.
Please let me know if it doesn't make sense.
@@ -18,6 +18,7 @@ body.is-reader-full-post { | |||
); | |||
|
|||
height: $feed-content-height !important; // Using !important here to avoid having a lengthy selector. | |||
overflow-y: hidden !important; // Keeps the scrolling container consistent between one and two column layouts. |
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.
meaning we were no longer getting events
I understand the motivation, but looks like this had a side-effect. In the reader recent tab, if you scroll down while reading a longish post and click on another post, the scroll position doesn't reset to the top of the post.
We fixed it here should you want to see the before and after videos, but I suspect this change makes it come back since it doesn't happen on trunk.
@spsiddarthan Thank you for that catch! I unintentionally removed that code. Should be fixed 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.
Works well, thanks for your work on this!
Fixes Automattic/loop#300
Proposed Changes
Why are these changes being made?
Testing Instructions
/read
and navigate between full post viewscalypso_reader_article_scroll_depth
loggedcalypso_reader_article_exit_before_completion
should also be logged.recordTrackForPost
method.Pre-merge Checklist