Sharing: native share popup pops up to first post
Impacted plugin
Jetpack
Quick summary
When using the native share button in a post list template in a block theme, the "Copied to clipboard" popup pops up next to the first instance of the button on the page.
Steps to reproduce
- Install and activate Jetpack
- go to Appearance> Editor
- Edit a template that displays a list of posts.
- Add a sharing buttons block
- Add a native share sharing service
- Save your changes
- On the frontend, view that list of posts
- Click on the native share button next to a post down on the page.
A clear and concise description of what you expected to happen.
On desktop, a "coped to clipboard" popup appears next to the button
What actually happened
The popup appears next to the first post on the page.
Impact
All
Available workarounds?
No but the platform is still usable
If the above answer is "Yes...", outline the workaround.
No response
Platform (Simple and/or Atomic)
Simple, Atomic, Self-hosted
Logs or notes
Reported here: https://www.reddit.com/r/jetpack/s/Njg1JLKHXX
📌 REPRODUCTION RESULTS
- Tested on Simple – Replicated
- Tested on Atomic – Replicated
- Replicable outside of Dotcom – Yes
📌 FINDINGS/SCREENSHOTS/VIDEO
There is no console error.
📌 ACTIONS Triaged
I was able to reproduce this, although chrome on Macos doesn't do the same behaviour (Firefox does).
The cause is here: https://github.com/Automattic/jetpack/blob/trunk/projects/plugins/jetpack/extensions/blocks/sharing-buttons/view.js#L42, so it looks like we just need to update the JS to call the element which relates to it, rather than any element containing that class.