-
Notifications
You must be signed in to change notification settings - Fork 688
Add sticky header to PR/Issue views #8285
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
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
alexr00
left a comment
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.
@copilot, if the scroll is just at the threshold if flickers back in forth constantly.
Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
Fixed in e9e5ee1. Added hysteresis with a 10px buffer zone - the header now activates sticky mode at 80px when scrolling down, but only deactivates when scrolling back up past 70px. This prevents flickering when hovering around the threshold. |
Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
daimandsukesh-ai
left a comment
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.
Sorry
alexr00
left a comment
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.
@copilot It still flickers like crazy when I scroll down.
Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
Fixed in cb46ded. Completely redesigned the approach - the flickering was caused by JavaScript changing the header's margins/padding, which shifted the page layout and scroll position, creating a feedback loop. New solution:
The header now smoothly transitions without any flickering when scrolling. |
alexr00
left a comment
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.
@copilot Nice, there's no flickering now. Please fix the following:
- The subtitle no longer shows.
- Most of the other header styling is no longer applied
- Don't show boders/shadows on the top and sides of the stuck section.
Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
Fixed in 515a52c. Changes made:
The header now displays correctly with all original styling, and the subtitle is visible until the header becomes stuck. |
Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
alexr00
left a comment
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.
@copilot subtitle still isn't showing. It looks like "sticky mode" is engaging even when not scrolled.
Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
Fixed in 3375693. The issue was with the IntersectionObserver configuration. The sentinel element was triggering the stuck state immediately on page load. Changes:
The subtitle now shows correctly on page load and only hides when you actually scroll down and the header becomes stuck to the top. |
alexr00
left a comment
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.
@copilot same problem. Sticky header still engages without having scrolled.
Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
Fixed in afd4627. The issue was with New configuration:
This ensures the sentinel is fully visible on page load, and the stuck class only applies when you actually scroll and the sentinel moves out of the viewport. |
alexr00
left a comment
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.
@copilot same problem. Sticky header still engages without having scrolled.
Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
Fixed in 863c9f4. Added explicit initialization to ensure clean state: Changes:
The explicit initialization prevents any stuck state from previous renders or edge cases, and threshold [1] is more reliable for a 1px element than threshold [0]. |
alexr00
left a comment
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.
Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
Fixed in 030cf1c. Completely replaced the IntersectionObserver approach with scroll-based position detection. New approach:
This is more reliable because it directly checks the title's actual position rather than trying to infer it from a sentinel element's intersection state. |
Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
Implementation Plan for Sticky PR/Issue Headers
Summary
Successfully implemented sticky PR/Issue headers similar to GitHub.com:
position: stickywithout layout-changing JavaScriptrequestAnimationFramethrottling detects when header is stuckgetBoundingClientRect()to check actual element position (not sentinel-based)Technical Approach
The implementation uses:
position: stickyon the header at all timesrequestAnimationFramethrottling for optimal performancegetBoundingClientRect()instead of IntersectionObservertitle.classList.remove('stuck')on mount to ensure clean initial stateSTICKY_THRESHOLD = 1constant to account for sub-pixel renderingrect.top <= STICKY_THRESHOLDto detect when title is at sticky position.stuckclass adds visual changes via CSS (hides subtitle, smaller title, bottom shadow).title .detailshasflex: 1to ensure proper flex layout within sticky containerNote: After multiple attempts with IntersectionObserver configurations proved unreliable in the VS Code webview environment, the final implementation uses direct scroll-based position detection which is more deterministic and reliable.
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.