Page MenuHomePhabricator

[ShareHighlight] Edge cases for selection and text fragment URLs
Closed, ResolvedPublic3 Estimated Story Points

Description

Couple edge cases to resolve further for text selections and text fragment URL generation for Share Highlight experiment, that were out of scope for the original cleanup of fragment generation in T417105:

  • text matching happens within a single block-level element:
    • spec - https://wicg.github.io/scroll-to-text-fragment/#finding-ranges-in-a-document
    • thus selections that span two paragraphs will have to have their fragment cut down to the text from the first para or other block element element
    • must be handled in useTextSelection.js when dealing with the Selection and Range
    • note that if we add prefix/suffix context to disambiguate matches, *those* can come from a separate block element but must each be within a block element
  • text matches require that the match start and end on a word boundary

Event Timeline

HSwan-WMF set the point value for this task to 3.Mar 31 2026, 4:24 PM
SherryYang-WMF lowered the priority of this task from High to Medium.Mar 31 2026, 9:20 PM
SherryYang-WMF raised the priority of this task from Medium to High.Apr 10 2026, 11:34 PM
mfossati changed the task status from Open to In Progress.Apr 21 2026, 11:58 AM

Some simpler fallback solutions if "rounding to word boundary" is too complicated:

  • fall back to section-level sharing (don't include a text fragment)
  • don't show the share button at all if the user has an invalid selection (spans across paragraphs, ends mid-word, etc)

I think the first one is probably the best bet.

Change #1278492 had a related patch set uploaded (by Marco Fossati; author: Marco Fossati):

[mediawiki/extensions/ReaderExperiments@master] ShareHighlight: text selection edge cases

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

Change #1278492 merged by jenkins-bot:

[mediawiki/extensions/ReaderExperiments@master] ShareHighlight: text selection edge cases & word-based activation

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

Etonkovidova subscribed.

Checked on articles with various content organization, including formulas, musical notation, tables, images with captions and with non-displayed captions - a share card handles reasonably.

I added additional cases to be checked in prod to T424667: [QA task] Share highlight - production check