Repository navigation
fix(blocks): handle each Share tap once when feeds are nested - #198
Merged
Merged
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Resolve the missing copy announcement for capped nested feeds and add the reader-facing README documentation.
1 open finding
🧠 Review effort: Lite
Give feedback about Copilot approvals in this survey to enter a drawing for a $150 gift card.
Member
Author
|
On Copilot's review:
|
Contributor
|
Hey @miguelpeixe, good job getting this PR merged! 🎉 Now, the Please check if this PR needs to be included in the "Upcoming Changes" and "Release Notes" doc. If it doesn't, simply remove the label. If it does, please add an entry to our shared document, with screenshots and testing instructions if applicable, then remove the label. Thank you! ❤️ |
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.

A Rolling Coverage feed can sit inside another feed's entry. When a reader tapped Share in the inner feed, both feeds handled the tap. On a device with a share sheet, the link was also copied, and a copy notice appeared while the sheet was still open. Without a share sheet, the link was copied twice. An entry with no title of its own, as in the Stream layout, could also share the title of an entry in the feed nested inside it.
What changes
Each Share tap is now handled once, by the feed closest to the button. Feeds that reach the page later, through the Load More button or new updates, keep working.
With this change:
How to test
trunk, runnpm run build, open the page in Chrome on Android, and tap Share on an "Inner" entry.The share sheet opens, and a "Link copied." or "Couldn't copy the link." notice also appears.
npm run build, and repeat step 4.Only the share sheet opens, with no copy notice.
One "Link copied." notice appears, and the button returns to "Share" after about two seconds.
It shares or copies once, and the page doesn't navigate.
The shared title is the page's title, not an "Inner" entry's title.
Technical details
Root cause.
src/blocks/share/view.tsadds click and keydown listeners to each feed present at load. A tap in a nested feed bubbles to every feed around it, and each listener ranhandleShareClick(). With Web Share, the second run'snavigator.share()is refused while the sheet is open, so it falls through to the copy. Two of its lookups also ignored nesting:root.querySelector()for the status region (a capped feed renders none, so it found a nested feed's), andclosest( 'article' )?.querySelector()for the title (the Stream and Minute layouts render no Post Title).The fix.
WeakSetof handled events lets only the closest feed with listeners handle each event.ownElement()applies the rule from the feed's own script (fix(blocks): keep a feed from acting on a feed nested in its entries #135), and both lookups go through it.Two alternatives were set aside. Ignoring buttons whose closest feed isn't
rootbreaks feeds added after load (load more, polls, the jump to the live feed), which get no Share listeners; their taps would follow the link. One document-level listener, as #137 did for Follow, would also work, but it misses taps when a wrapper stops propagation.Verification.
tsc --noEmitand lint pass. A Playwright check ran the built script in real Chromium on routed pages, with stand-ins fornavigator.shareandClipboard.writeText(). It covers 19 scenarios: nested taps with and without Web Share, Space, the icon-only and legacy buttons, capped feeds, feeds added after load (one and two levels deep), untitled entries, and modified clicks. 11 fail ontrunk; none fail on this branch. Not checked on a device.With the stand-in
writeText()settling in a later task, as on HTTPS, a nested copy ontrunkalso left the button reading "Copied!" for good. That isn't confirmed in a real browser.The "Link copied." status region is used only without Newspack UI. With it, the notice is a snackbar.
Self-review: two rounds (Newspack WP expert (Claude Opus 5.5), deep reviewer (Claude Opus 5.5)), no blockers fixed.
🤖 Generated with Claude Code