From e8d1fd83291a8676cd7674e671fab8c25bae4d7a Mon Sep 17 00:00:00 2001 From: Paul Kevan <2290623+pkevan@users.noreply.github.com> Date: Wed, 15 Jan 2025 09:55:09 +0000 Subject: [PATCH] Sharing Block > Native sharing: use relevant link for popup (#41002) * Use relevant link for sharing popup See: #39060. This switches the tooltip to use the associated link, rather than any element containing the `tooltiptext` class within the page. --- .../plugins/jetpack/changelog/fix-sharing-dialog-location | 4 ++++ .../plugins/jetpack/extensions/blocks/sharing-buttons/view.js | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 projects/plugins/jetpack/changelog/fix-sharing-dialog-location diff --git a/projects/plugins/jetpack/changelog/fix-sharing-dialog-location b/projects/plugins/jetpack/changelog/fix-sharing-dialog-location new file mode 100644 index 0000000000000..305163f8beda8 --- /dev/null +++ b/projects/plugins/jetpack/changelog/fix-sharing-dialog-location @@ -0,0 +1,4 @@ +Significance: patch +Type: bugfix + +Sharing: Fix the location of the sharing dialog, so it is not always the first sharing element on the page diff --git a/projects/plugins/jetpack/extensions/blocks/sharing-buttons/view.js b/projects/plugins/jetpack/extensions/blocks/sharing-buttons/view.js index 524eb9668c995..90169f1f19989 100644 --- a/projects/plugins/jetpack/extensions/blocks/sharing-buttons/view.js +++ b/projects/plugins/jetpack/extensions/blocks/sharing-buttons/view.js @@ -39,7 +39,7 @@ if ( typeof window !== 'undefined' ) { if ( link?.href && isWebShareAPIEnabled( { url: link.href } ) ) { navigator.share( { url: link.href } ); } else { - const [ tooltip ] = document.getElementsByClassName( 'tooltiptext' ); + const [ tooltip ] = link.getElementsByClassName( 'tooltiptext' ); if ( tooltip && tooltip.style ) { tooltip.style.display = 'initial'; setTimeout( () => {