Bug/STC-469: Highlight and scroll to activity comment on anchor change#23894
Draft
akabiru wants to merge 4 commits into
Draft
Bug/STC-469: Highlight and scroll to activity comment on anchor change#23894akabiru wants to merge 4 commits into
akabiru wants to merge 4 commits into
Conversation
|
Warning Flaky specs
🤖 Ask Copilot to investigateCopy the prompt below into a new comment on this PR to delegate the investigation to GitHub Copilot. It will look into the flakiness and open a separate pull request with you as reviewer. |
|
Warning Flaky specs
🤖 Ask Copilot to investigateCopy the prompt below into a new comment on this PR to delegate the investigation to GitHub Copilot. It will look into the flakiness and open a separate pull request with you as reviewer. |
Changing the activity URL hash without a page load (an in-page comment link or a manual URL edit) left the referenced comment un-highlighted and un-scrolled, since scrolling only ran on initial render. Add a hashchange handler that highlights and scrolls to the comment, positioned relative to the scroll container so it lands correctly in every activity-tab context. Legacy activity-N anchors are left to the server, which a hash change cannot reach. Ref: STC-469
A comment-reference link in a comment body is a plain link inside the activities turbo-frame, so Turbo claimed the click as a frame/page visit and dropped the #comment fragment, leaving the referenced comment un-scrolled and un-highlighted. Intercept clicks on links that point to a comment on the current activity page and route them through the hash, letting the hashchange handler scroll and highlight. Links to other pages and external links are left untouched. Ref: STC-469
b12d717 to
f3579b0
Compare
Address review findings on the activities hashchange handling. The window hashchange listener fires on every live controller, so resolve the anchor element within this.element rather than the document, and construct the AbortController in connect so a reconnect rebinds its listeners. Only claim an in-content comment click when the target is rendered here, otherwise let it navigate instead of swallowing it into a hash change that resolves to nothing. Drop the fixed sleeps in the specs; the highlight assertion already waits.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
STC-469
Updating the activity-tab anchor without a full page load didn't scroll to or highlight the referenced comment - whether clicking a comment-reference link inside another comment, or editing
#comment-<id>in the address bar.Two separate causes. The auto-scrolling controller only acted on initial render, so later hash changes were ignored; a
hashchangelistener now reacts to all of them. And a comment-reference link is a plain link inside the activities Turbo frame, so Turbo claimed the click as a navigation and dropped the fragment before anything could react; same-page comment links are now routed through the hash, while links to other pages and external links are left untouched.Legacy
#activity-<n>anchors aren't handled on a hash change, since resolving a sequence version to a comment needs the server, which a same-page hash change never reaches.highlight-on-click.mp4