Page MenuHomePhabricator

shareHighlight - if headers were highlighlited, Share card shows "edit" word
Closed, ResolvedPublic2 Estimated Story PointsBUG REPORT

Description

Some non-content text (e.g. "edit" link, footnote links, ...) gets included in the selected text.
While we may need those in the share url, we do not want them to be included in shared output.

Steps to replicate the issue:

Screenshot 2026-04-16 at 5.07.29 PM.png (786×1,728 px, 314 KB)

What happens?:

  • the Share card for the text highlighted in the content in the screenshot above will incorrectly shows
    • the lead image (filed as /T423603)
    • and the word edit (the edit icon was inadvertently included into the highlighted text)

Screenshot 2026-04-16 at 5.07.42 PM.png (800×1,742 px, 611 KB)

What should have happened instead?:

  • a Share card should show only user-visible content

Acceptance criteria

  • non-content text (e.g. "edit" link, footnote links, ...) is still included in the share url as needed
    • broken in current patch; fix planned to return two forms of the text, with and without exclusions
  • non-content text (e.g. "edit" link, footnote links, ...) is not included in the shared output
    • done in current patch

Event Timeline

This appears to have been reduced but not fully eliminated by the patch for T421160 (selection edge cases) -- ensuring that we only take from a single block element means we can only end up with the "edit" button if the user has managed to select _none_ of the section title (which is an <h2> or sometimes <h1>) and _has_ gotten the selection onto the <span> with the edit link, outside the h2.

image.png (894×648 px, 31 KB)

image.png (885×543 px, 42 KB)

Setting user-select: none on .mw-editsection appears to handily exclude the section edit links from the selection, and therefore any remaining edge cases where we would extract that text. (And if we later change to allow scraping across block levels, it will still work without needing to be changed.)

This also has the bonus of excluding the "edit" links from copy/paste of text across heading boundaries, where no user has ever wanted it. ;) So this might be something to more to core later.

Change #1284018 had a related patch set uploaded (by Bvibber; author: Bvibber):

[mediawiki/extensions/ReaderExperiments@master] [Share Highlight] Excluse section edit links from selection

https://gerrit.wikimedia.org/r/1284018

About to push new patchset which handles the exclusions without breaking fragments :D

image.png (794×1,348 px, 241 KB)

image.png (842×1,520 px, 925 KB)

bvibber subscribed.
bvibber unsubscribed.

Change #1284018 merged by jenkins-bot:

[mediawiki/extensions/ReaderExperiments@master] [Share Highlight] Exclude section edit links, footnotes from selection

https://gerrit.wikimedia.org/r/1284018

Change #1286518 had a related patch set uploaded (by Jdlrobson; author: Brooke Vibber):

[mediawiki/extensions/ReaderExperiments@wmf/1.47.0-wmf.2] [Share Highlight] Exclude section edit links, footnotes from selection

https://gerrit.wikimedia.org/r/1286518

Change #1286518 merged by jenkins-bot:

[mediawiki/extensions/ReaderExperiments@wmf/1.47.0-wmf.2] [Share Highlight] Exclude section edit links, footnotes from selection

https://gerrit.wikimedia.org/r/1286518

Mentioned in SAL (#wikimedia-operations) [2026-05-13T13:27:13Z] <mfossati@deploy1003> Started scap sync-world: Backport for [[gerrit:1286518|[Share Highlight] Exclude section edit links, footnotes from selection (T423658)]], [[gerrit:rEWBA128683823dcc|Add robust color fallbacks for QuoteCard average-color styling (T425358)]], [[gerrit:1286839|Fixed card width (T425710)]], [[gerrit:1286844|Adjust image size to match fixed width (T425710)]], [[gerrit:1286846|ShareHighlight: exclude browsers th

Mentioned in SAL (#wikimedia-operations) [2026-05-13T13:29:09Z] <mfossati@deploy1003> jdlrobson, mfossati: Backport for [[gerrit:1286518|[Share Highlight] Exclude section edit links, footnotes from selection (T423658)]], [[gerrit:rEWBA128683823dcc|Add robust color fallbacks for QuoteCard average-color styling (T425358)]], [[gerrit:1286839|Fixed card width (T425710)]], [[gerrit:1286844|Adjust image size to match fixed width (T425710)]], [[gerrit:1286846|ShareHighlight: exclude browsers that d

Mentioned in SAL (#wikimedia-operations) [2026-05-13T13:40:29Z] <mfossati@deploy1003> Finished scap sync-world: Backport for [[gerrit:1286518|[Share Highlight] Exclude section edit links, footnotes from selection (T423658)]], [[gerrit:rEWBA128683823dcc|Add robust color fallbacks for QuoteCard average-color styling (T425358)]], [[gerrit:1286839|Fixed card width (T425710)]], [[gerrit:1286844|Adjust image size to match fixed width (T425710)]], [[gerrit:1286846|ShareHighlight: exclude browsers t

Checked on itwiki wmf.2 - the issue is fixed. The specific article in the task descirption - https://it.wikipedia.org/wiki/Charlie_Parker?shareHighlight=1&uselang=en will display "TypeError: parsedUrl.resizeUrl is not a function" (T425149 ) , Checked other articles:

Below are the screenshots showing the correct share card text despite highlighting (selecting) across sections. Also, the references are also not included in a share card:

Screenshot 2026-05-13 at 4.48.48 PM.png (1,458×1,638 px, 480 KB)
Screenshot 2026-05-13 at 4.49.14 PM.png (1,292×1,432 px, 349 KB)
Screenshot 2026-05-13 at 4.49.57 PM.png (2,150×1,624 px, 1021 KB)

//Note:// There are still edge cases when non-user visible context is displayed. Should be there a follow-up task specifically for edge cases?
-https://it.wikipedia.org/wiki/Campionato_mondiale_di_beach_soccer_2024?shareHighlight=1&uselang=en

Screenshot 2026-05-13 at 4.13.45 PM.png (2,076×1,782 px, 528 KB)
Screenshot 2026-05-13 at 4.13.20 PM.png (856×1,152 px, 128 KB)
lwatson subscribed.

Thanks @Etonkovidova! Please file the edge cases, like the hatnote, in a new ticket.