Skip to content

Load more timeline items when clicking a link to an unloaded comment - #393

Merged
NicolasBonet merged 1 commit into
mainfrom
nicolas/load-more-until-anchor
Oct 7, 2026
Merged

NicolasBonet merged 1 commit into
mainfrom
nicolas/load-more-until-anchor

Conversation

@NicolasBonet

Copy link
Copy Markdown
Contributor

Problem

On long issues and PRs, GitHub collapses the middle of the timeline behind a "N remaining items / Load more" control. Clicking a link to a comment on the same page (eg. #issuecomment-123 or https://github.com/org/repo/pull/1#discussion_r456) does nothing when that comment is inside the collapsed section, because the target isn't in the DOM yet.

Solution

Add loadMoreUntilAnchor, initialized on the issue and PR pages. It listens for plain left-clicks on links whose URL points at the current issue/PR path with a hash. If the target element (or its user-content- markdown heading variant) isn't in the DOM, it polls every 250ms:

  1. If the target exists, scroll to it and stop.
  2. Otherwise click every available load-more control: button[data-testid^="issue-timeline-load-more-"], button[data-testid="hidden-items-expander"] and button.ajax-pagination-btn, skipping ones that are disabled or have data-loading="true".

It stops after 30 seconds, after 3 seconds with no load-more control left, or when the user scrolls or presses a key. It runs independently of the auto load more comments preference.

Fixed Issues

None

Tests

  1. Run npm run lint and confirm no errors.
  2. Run npm run build and load dist as an unpacked extension.
  3. Turn off the auto load more comments toggle.
  4. Open a long issue or PR that shows "N remaining items".
  5. Click a link on that page to a comment hidden in the collapsed section.
  6. Confirm "Load more" is clicked repeatedly until the comment appears and the page scrolls to it.
  7. Repeat step 5 and scroll the page while it is loading. Confirm loading stops and the page does not jump.
  8. Click a link to a comment that is already visible. Confirm "Load more" is not clicked.

@NicolasBonet
NicolasBonet requested a review from a team October 6, 2026 18:23
@melvin-bot
melvin-bot Bot requested review from inimaga and removed request for a team October 6, 2026 18:24
@NicolasBonet
NicolasBonet merged commit 1b49848 into main Oct 7, 2026
5 of 6 checks passed
@NicolasBonet
NicolasBonet deleted the nicolas/load-more-until-anchor branch October 7, 2026 13:00
@os-botify

os-botify Bot commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

🚀 Released in version 1.5.70 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants