fix(watch-fork-star-popup): portal popup out of the stargazers anchor#39
Merged
Conversation
The star/fork counters are GitHub's own `<a href=".../stargazers">` / `<button>`, and the popup was appended inside them. That trapped the popup's user links as nested anchors inside the stargazers anchor, so clicking a stargazer (avatar, name, or blank space) resolved to the wrapping anchor and navigated to the stargazers list instead of the user's profile. The earlier stopPropagation fix (#35) couldn't help: GitHub binds clicks in the capture phase (our bubble-phase handler runs too late), and nested anchors are invalid HTML with no spec'd activation target — and stopPropagation can't override the default navigation anyway. Portal the popup to <body> and position it with `position: fixed` so it lives outside any anchor. User links then navigate natively (keeping Cmd/Ctrl/middle- click new-tab for free) and blank-area clicks hit nothing. - Drop the stopPropagation hack and the re-attach MutationObserver (the popup is no longer a child of the counter, so GitHub re-rendering it is harmless). - Reap orphaned body popups on inject so SPA navigations don't leak them. - Cancel the close timer on counter re-entry to avoid a flicker now that leaving the counter for the popup fires mouseleave.
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.
Problem
Clicking a stargazer (avatar / name / blank space) in the star popup still navigated to the stargazers list instead of the user's profile — the bug #35 tried, but failed, to fix.
The root cause: the star/fork counters are GitHub's own
<a href=".../stargazers">/<button>. The popup was appended inside them, so the popup's user links became nested anchors trapped inside the stargazers anchor.The earlier
stopPropagationfix couldn't work:<a>is invalid HTML with no spec'd activation target, andstopPropagationdoesn't override default navigation anyway.Fix
Stop nesting the popup inside the anchor entirely — portal it to
<body>and position it withposition: fixedcomputed from the counter's rect. Now:stopPropagationhack needed.Changes
watch-fork-star-popup.ts: append popup todocument.body; position viagetBoundingClientRect()inshow().stopPropagationinterceptor and the re-attachMutationObserver(popup is no longer a child of the counter, so GitHub re-rendering the counter is harmless).reapOrphanedPopups()(tracked via aWeakMap) so SPA navigations don't leak orphaned body-level popups.mouseleave.content.css:.bg-wfs-popupposition: absolute→fixed(top/left set by JS).Tests
<body>and is not inside the stargazers anchor; orphaned popups are reaped on re-inject.