Repository navigation
feat(MainTable): add scrollToTop prop to scroll to the top on page change - #1432
Conversation
…ange Paginated MainTables render a Pagination component internally, but there was no way to enable Pagination's scrollToTop behaviour from the table. Add a scrollToTop prop that is passed through to the pagination so the window scrolls to the top when the table page changes. Fixes canonical#34
|
@edlerd @jmuzina could you take a look when you have a moment? @bartaz this picks up #34, which you triaged as low effort / potentially high value. I went with an opt-in |
Stefan3002
left a comment
There was a problem hiding this comment.
@wak327 Hello! Thanks for picking this up and proposing a fix! Looks good with only one suggestion: can we have a new story underMainTable.stories.tsx with a lot of rows? This would make it easier to visualize the behavior of the component. As of now, I can zoom in a lot and cause it to overflow vertically and then test this new functionality, but it would be easier if we had a dedicated story.
Other than that, looks good! Great job! 😄
Add a paginated story with enough rows for the page to scroll, so the scrollToTop behaviour is easier to see.
|
@Stefan3002 thanks for the review! I've added a "Paginated with scroll to top" story with 100 rows across 4 pages and |
Stefan3002
left a comment
There was a problem hiding this comment.
Hello! Thanks for the work here! Well done!
LGTM! 😄
|
🎉 This PR is included in version 4.15.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Done
scrollToTopprop toMainTable. It is passed to the table's internalPagination, so the window scrolls to the top when the table page changes. It is off by default, so existing tables behave as before.scrollToTopis set, and not scrolling by default.QA
Pinging @canonical/react-library-maintainers for a review.
Storybook
To see rendered examples of all react-components, run:
QA in your project
from
react-componentsrun:Install the resulting tarball in your project with:
QA steps
MainTablewithpaginateset, enough rows for more than one page, andscrollToTop.scrollToTopand change the page again: the scroll position doesn't change.Percy steps
Fixes
Fixes: #34