Skip to content

fix: support text selection under search highlights#20463

Merged
timvandermeij merged 1 commit intomozilla:masterfrom
matt-atticus:fix-text-selection-under-search-highlight
Feb 17, 2026
Merged

fix: support text selection under search highlights#20463
timvandermeij merged 1 commit intomozilla:masterfrom
matt-atticus:fix-text-selection-under-search-highlight

Conversation

@matt-atticus
Copy link
Contributor

@matt-atticus matt-atticus commented Nov 26, 2025

Fixes an issue where highlighted search results interfere with text selection. From what we can tell, the issue stems from moving .endOfContent to the search highlight span, preventing the selection range from being extended.

Steps to reproduce the issue:

  1. Open the pdf.js demo viewer at https://mozilla.github.io/pdf.js/web/viewer.html
  2. Use the toolbar to search for a keyword e.g. "javascript"
  3. Try to create a text selection range that begins inside of, ends inside of, or spans the highlighted search result.
  4. Observe various issues:
    • flickering
    • individual characters in the search highlight cannot be smoothly selected/deselected when dragging
pdfjs-highlight-issue.mov

The fix was tested on the demo viewer locally:

npx gulp dist-install && npx gulp server

# http://localhost:8888/web/viewer.html
pdfjs-highlight-fix.mov

@matt-atticus matt-atticus marked this pull request as ready for review December 1, 2025 02:26
@nicolo-ribaudo
Copy link
Contributor

/botio preview

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Windows)


Received

Command cmd_preview from @nicolo-ribaudo received. Current queue size: 0

Live output at: http://54.193.163.58:8877/a81d0fc6ccd40ac/output.txt

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Linux m4)


Received

Command cmd_preview from @nicolo-ribaudo received. Current queue size: 0

Live output at: http://54.241.84.105:8877/b10e44dc6200d7d/output.txt

@nicolo-ribaudo
Copy link
Contributor

(this PR should be labeled as chrome-specific)

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Linux m4)


Success

Full output at http://54.241.84.105:8877/b10e44dc6200d7d/output.txt

Total script time: 0.99 mins

Published

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Windows)


Success

Full output at http://54.193.163.58:8877/a81d0fc6ccd40ac/output.txt

Total script time: 3.51 mins

Published

@nicolo-ribaudo
Copy link
Contributor

/botio integrationtest

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Linux m4)


Received

Command cmd_integrationtest from @nicolo-ribaudo received. Current queue size: 0

Live output at: http://54.241.84.105:8877/09db56172e1d42e/output.txt

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Windows)


Received

Command cmd_integrationtest from @nicolo-ribaudo received. Current queue size: 0

Live output at: http://54.193.163.58:8877/68ec04988f22474/output.txt

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Linux m4)


Success

Full output at http://54.241.84.105:8877/09db56172e1d42e/output.txt

Total script time: 20.46 mins

  • Integration Tests: Passed

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Windows)


Success

Full output at http://54.193.163.58:8877/68ec04988f22474/output.txt

Total script time: 40.20 mins

  • Integration Tests: Passed

@matt-atticus matt-atticus force-pushed the fix-text-selection-under-search-highlight branch 2 times, most recently from 67487f1 to 5421859 Compare February 13, 2026 03:18
@timvandermeij
Copy link
Contributor

/botio integrationtest

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Linux m4)


Received

Command cmd_integrationtest from @timvandermeij received. Current queue size: 0

Live output at: http://54.241.84.105:8877/9fb19f94424d64c/output.txt

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Windows)


Received

Command cmd_integrationtest from @timvandermeij received. Current queue size: 0

Live output at: http://54.193.163.58:8877/9a278e12cdfa190/output.txt

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Linux m4)


Success

Full output at http://54.241.84.105:8877/9fb19f94424d64c/output.txt

Total script time: 21.79 mins

  • Integration Tests: Passed

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Windows)


Failed

Full output at http://54.193.163.58:8877/9a278e12cdfa190/output.txt

Total script time: 46.15 mins

  • Integration Tests: FAILED

@timvandermeij
Copy link
Contributor

/botio-linux preview

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Linux m4)


Received

Command cmd_preview from @timvandermeij received. Current queue size: 1

Live output at: http://54.241.84.105:8877/2e9c9e57d346c7a/output.txt

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Linux m4)


Success

Full output at http://54.241.84.105:8877/2e9c9e57d346c7a/output.txt

Total script time: 1.01 mins

Published

@timvandermeij
Copy link
Contributor

Looks good! Please squash the commits to have a single commit with a good commit message that explains the change (see https://github.com/mozilla/pdf.js/wiki/Squashing-Commits if you're not familiar with how to do that). We can merge this afterwards. Thanks!

@matt-atticus matt-atticus force-pushed the fix-text-selection-under-search-highlight branch from 5421859 to f01e4d4 Compare February 17, 2026 02:47
@matt-atticus
Copy link
Contributor Author

Looks good! Please squash the commits to have a single commit with a good commit message that explains the change (see https://github.com/mozilla/pdf.js/wiki/Squashing-Commits if you're not familiar with how to do that). We can merge this afterwards. Thanks!

Done - thanks! 🙏

@marco-c
Copy link
Contributor

marco-c commented Feb 17, 2026

It would be great if we could also fix #18190 (and https://bugzilla.mozilla.org/show_bug.cgi?id=1972953).

@timvandermeij timvandermeij merged commit 178261a into mozilla:master Feb 17, 2026
10 checks passed
@timvandermeij
Copy link
Contributor

Thank you for your contribution!

@codecov-commenter
Copy link

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 59.77%. Comparing base (62ac1b8) to head (f01e4d4).
⚠️ Report is 6 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #20463      +/-   ##
==========================================
- Coverage   59.78%   59.77%   -0.02%     
==========================================
  Files         169      169              
  Lines       90165    90165              
==========================================
- Hits        53907    53894      -13     
- Misses      36258    36271      +13     
Flag Coverage Δ
unittestcli 59.77% <ø> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants