[#2542] Add scroll button component and implement on views#2556
[#2542] Add scroll button component and implement on views#2556FisherSkyi merged 30 commits intoreposense:masterfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a “scroll back to top” affordance to the report UI by introducing a reusable scroll-to-top button and wiring it into the main report panes.
Changes:
- Added a new
c-scroll-top-buttonVue component that shows/hides based on a scroll container’s scroll position and scrolls back to top on click. - Integrated the button into the summary pane and the right-side tab views (authorship + global file browser).
- Registered the Font Awesome
arrow-upicon and added Cypress coverage for the new button behavior.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| frontend/src/views/c-summary.vue | Renders the scroll-to-top button for the summary pane (#summary-wrapper). |
| frontend/src/views/c-scroll-top-button.vue | New scroll-to-top button component (scroll listener + UI + styling). |
| frontend/src/views/c-global-file-browser.vue | Renders the scroll-to-top button for the right tab pane (#tabs-wrapper). |
| frontend/src/views/c-authorship.vue | Renders the scroll-to-top button for the right tab pane (#tabs-wrapper). |
| frontend/src/utils/load-font-awesome-icons.ts | Adds faArrowUp to the Font Awesome library. |
| frontend/cypress/tests/globalBrowserView/globalBrowserView_scrollButton.cy.js | Cypress coverage for scroll-to-top button in global file browser view. |
| frontend/cypress/tests/chartView/chartView_scrollButton.cy.js | Cypress coverage for scroll-to-top button in the summary/chart view. |
Update on copilot's review:
Rationale:
|
|
The following links are for previewing this pull request:
|
| padding: 0; | ||
| place-content: center; | ||
| place-items: center; | ||
| position: sticky; |
There was a problem hiding this comment.
Using position: sticky here keeps the button in normal document flow. Because the button is rendered after all content in each scroll container, it won’t be reachable/visible until the user scrolls near the bottom of the container (defeating the purpose of a “back to top” control for long reports). Consider positioning it out of flow (e.g., position: absolute within a position: relative scroll container, or position: fixed with appropriate container scoping) so it can appear whenever showBackToTop becomes true.
| position: sticky; | |
| position: fixed; |
There was a problem hiding this comment.
From a practical perspective fixed will cause the left and right buttons overlap as they are both positioned relative to the viewpoint. But help and suggestions are welcome here as I don't really understand the mechanism of css layout.
There was a problem hiding this comment.
Regarding this issue, yes, position: fixed won't work here. position: sticky does technically work (the button sticks to the bottom of the visible scroll area since it's the last child in the container), but it stays in document flow and can cause layout shifts.
The cleaner fix might be position: absolute scoped to each panel:
- Add
position: relativeto#summary-wrapperinstyle.scss). - Change the button to
position: absolute; bottom: 20px; right: 20pxand removemargin-left: auto. - Make sure
c-scroll-top-buttonin the tabs panel out of.tab-pane/.tab-contentand make it a direct child of#tabs-wrapper, so it floats over the panel content rather than scrolling with it. The summary panel button is already placed correctly.
This keeps each button scoped to its own panel, out of document flow, and visible at any scroll depth regardless of content length.
Can try this out though and see if it works!
There was a problem hiding this comment.
agree with ashmita here !
There was a problem hiding this comment.
The behavior with proposed fix: the button will scroll along with the segment, which is not desirable. Right now I think we can keep the sticky.
ashmitahaldar
left a comment
There was a problem hiding this comment.
Overall great work! Just some questions and inputs on the existing PR comments.
| padding: 0; | ||
| place-content: center; | ||
| place-items: center; | ||
| position: sticky; |
There was a problem hiding this comment.
Regarding this issue, yes, position: fixed won't work here. position: sticky does technically work (the button sticks to the bottom of the visible scroll area since it's the last child in the container), but it stays in document flow and can cause layout shifts.
The cleaner fix might be position: absolute scoped to each panel:
- Add
position: relativeto#summary-wrapperinstyle.scss). - Change the button to
position: absolute; bottom: 20px; right: 20pxand removemargin-left: auto. - Make sure
c-scroll-top-buttonin the tabs panel out of.tab-pane/.tab-contentand make it a direct child of#tabs-wrapper, so it floats over the panel content rather than scrolling with it. The summary panel button is already placed correctly.
This keeps each button scoped to its own panel, out of document flow, and visible at any scroll depth regardless of content length.
Can try this out though and see if it works!
| }); | ||
|
|
||
| it('shows the button when scroll more than 200 pixels', () => { | ||
| cy.get('#tabs-wrapper').scrollTo(0, 300).trigger('scroll'); |
There was a problem hiding this comment.
What does this .trigger('scroll') do? Why does test 2 and 3 use it but not test 1? Just a bit confused haha, would be good to understand.
There was a problem hiding this comment.
trigger will emit the event "scroll".
scroll is an event. It's handler is in c-home.vue line 48 #summary-wrapper(ref="summaryWrapper", @scroll="handleSummaryScroll")
trigger is needed, as cy.scrollTo() changes the element's scrollTop property in the DOM. But in test environments (on CI/CD env specifically), the native scroll event does not fire automatically
There was a problem hiding this comment.
@FisherSkyi Thanks for clarifying! Do you need to include it then in the other tests or no need?
jonasongg
left a comment
There was a problem hiding this comment.
lgtm other than the small comment!
| padding: 0; | ||
| place-content: center; | ||
| place-items: center; | ||
| position: sticky; |
There was a problem hiding this comment.
agree with ashmita here !
ashmitahaldar
left a comment
There was a problem hiding this comment.
Generally LGTM! Would just like you to check if .trigger() is needed on other tests, otherwise looks good to go.
I double checked and it seems Also while exploring I found another separate issue #2574 but it should be addressed in separate pr. |
| scrollTabsToTop(): void { | ||
| const el = this.$refs.tabWrapper as HTMLElement | undefined; | ||
| el?.scrollTo({ top: 0, behavior: 'smooth' }); | ||
| }, |
There was a problem hiding this comment.
Scrolling logic appears to be sound.
|
The following links are for previewing this pull request:
|
Fixes #2542
Proposed commit message
Other information
N/A