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

Dashboard: Prevent scroll to top on pagination #2883

Merged
merged 2 commits into from
Jul 1, 2020

Conversation

BrittanyIRL
Copy link
Contributor

@BrittanyIRL BrittanyIRL commented Jun 30, 2020

Summary

Omar identified a bug that we didn't notice with the update to implement scroll to top when you swap from 'all results' to 'draft' or 'publish', we didn't notice it because when that was implemented we were also loading 100 stories at a time so it wasn't as visible - now with our 24 results at a time it's noticeable :D
Bug
bad scroll

Solution
(pardon my glitchy recording)
Paginate without scrolling
paginate without scroll to top

Scroll up with switch in filter
switch to drafts scroll

Scroll to top on sort update
sort scroll to top

Relevant Technical Choices

  • moving scroll to top in dashboard to be associated with filtering by button clicks in header in stead of with body content, this prevents Content from scrolling to top when a new page is loaded and keeps the actions tight.
  • wrapped Content and Header in memo since they are pure components that load a lot of props with a lot of data. This will be expanded on later but for now just the default comparison.
  • slicing the first 5 results from returned stories to show in typeahead, there's no reason we need to send all of that to the typeahead when it's locked to show only the first 5, that said - i'm making a new ticket to implement scrolling on this - that was an iteration that got lost in the shuffle of more important matters.

To-do

  • Make a new ticket to enable scrolling on typeahead

User-facing changes

  • Scroll up on my stories should only occur when you click on another quick filter in the header area (all stories, draft, published)

Testing Instructions

  • Scroll down the list of stories in your dashboard, see that there's no attempt to send you to the top of the page again
  • click a different quick filter and see that you are scrolled to the top
  • scroll down the view and change the sort and see that you are scrolled to the top
  • Since I adjusted the quantity of data getting sent through to the typeahead verify that typeahead is still loading results

Addresses #2884

…status to prevent scroll to top on new page load. adding memo() to my stories content and header as they are pure components recieving the same props and LOTS of props. To expand on this later. Limiting search results to first 5 and memoizing, there is no need to pass the whole list of results to the typeahead right now as it is only showing the first few results. Note: come back and enable scrolling.
@codecov
Copy link

codecov bot commented Jun 30, 2020

Codecov Report

Merging #2883 into master will decrease coverage by 12.68%.
The diff coverage is 66.66%.

Impacted file tree graph

@@             Coverage Diff             @@
##           master    #2883       +/-   ##
===========================================
- Coverage   81.95%   69.27%   -12.69%     
===========================================
  Files         675      699       +24     
  Lines       10346    11875     +1529     
===========================================
- Hits         8479     8226      -253     
- Misses       1867     3649     +1782     
Flag Coverage Δ
#karmatests 21.08% <33.33%> (-38.77%) ⬇️
#unittests 66.61% <66.66%> (+0.03%) ⬆️
Impacted Files Coverage Δ
...src/dashboard/app/views/myStories/content/index.js 100.00% <ø> (+30.00%) ⬆️
.../src/dashboard/app/views/myStories/header/index.js 84.61% <60.00%> (-4.28%) ⬇️
...sets/src/dashboard/app/views/shared/pageHeading.js 100.00% <100.00%> (ø)
assets/src/edit-story/elements/image/icon.js 0.00% <0.00%> (-100.00%) ⬇️
assets/src/edit-story/elements/shape/icon.js 0.00% <0.00%> (-100.00%) ⬇️
assets/src/edit-story/elements/video/icon.js 0.00% <0.00%> (-100.00%) ⬇️
assets/src/edit-story/components/canvas/canvas.js 0.00% <0.00%> (-100.00%) ⬇️
...ssets/src/edit-story/components/canvas/navLayer.js 0.00% <0.00%> (-100.00%) ⬇️
...ssets/src/edit-story/components/workspace/index.js 0.00% <0.00%> (-100.00%) ⬇️
...ssets/src/edit-story/elements/image/textContent.js 0.00% <0.00%> (-100.00%) ⬇️
... and 149 more

@github-actions
Copy link
Contributor

github-actions bot commented Jun 30, 2020

Size Change: +8 B (0%)

Total Size: 996 kB

Filename Size Change
assets/js/stories-dashboard.js 526 kB +8 B (0%)
ℹ️ View Unchanged
Filename Size Change
assets/css/edit-story.css 269 B 0 B
assets/css/stories-dashboard.css 305 B 0 B
assets/css/web-stories-embed-block.css 515 B 0 B
assets/js/edit-story.js 453 kB 0 B
assets/js/web-stories-embed-block.js 15.7 kB 0 B

compressed-size-action

@BrittanyIRL BrittanyIRL linked an issue Jun 30, 2020 that may be closed by this pull request
Copy link
Contributor

@mariano-formidable mariano-formidable left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@BrittanyIRL BrittanyIRL changed the title moving scroll to top in dashboard to be associated with filtering by … Dashboard: Prevent scroll to top on pagination Jun 30, 2020
@@ -114,7 +125,13 @@ function Header({
handleLayoutSelect={view.toggleStyle}
currentSort={sort.value}
pageSortOptions={STORY_SORT_MENU_ITEMS}
handleSortChange={sort.set}
handleSortChange={useCallback(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: I'd have put this into a variable, e.g. const onHandleSortChange = useCallback(...)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i'll move this in my next pr - thanks!

@swissspidy
Copy link
Collaborator

Karma tests timed out, but will have to wait until #2887 is resolved for this to pass through normally.

@swissspidy swissspidy merged commit b4cda21 into master Jul 1, 2020
@swissspidy swissspidy deleted the fix/scroll-up-on-load-more-dashboard branch July 1, 2020 06:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Group: Dashboard Type: Bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Dashboard results scrolling to top on pagination
4 participants