Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix autolinking with highlighted search results #19576

Merged
merged 1 commit into from
Mar 2, 2025

Conversation

nicolo-ribaudo
Copy link
Contributor

The current logic assumes that all spans in the text layer contain only one text node, and thus that the position information returned by highlighter._convertMatches can be directly used on the element's only child.

This is not true in case of highlighted search results: they will be injected in the DOM as <span> elements, causing the <span>s in the text layer to have more than one child.

This patch fixes the problem by properly converting the (span, offset) pair in a (textNode, offset) pair that points to the right text node.

Fixes #19465

@nicolo-ribaudo nicolo-ribaudo force-pushed the fix-linkannotation branch 2 times, most recently from a1ac843 to 2a19f00 Compare February 28, 2025 14:06
@nicolo-ribaudo nicolo-ribaudo force-pushed the fix-linkannotation branch 2 times, most recently from 19774c1 to bd3f03b Compare February 28, 2025 14:28
@Snuffleupagus
Copy link
Collaborator

/botio integrationtest

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Linux m4)


Received

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

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

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Windows)


Received

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

Live output at: http://54.193.163.58:8877/0c51e5d9108c259/output.txt

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Linux m4)


Failed

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

Total script time: 12.63 mins

  • Integration Tests: FAILED

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Windows)


Failed

Full output at http://54.193.163.58:8877/0c51e5d9108c259/output.txt

Total script time: 29.53 mins

  • Integration Tests: FAILED

@nicolo-ribaudo
Copy link
Contributor Author

I didn't see that failure locally, I'll check what it is.

The current logic assumes that all spans in the text layer contain
only one text node, and thus that the position information
returned by `highlighter._convertMatches` can be directly used
on the element's only child.

This is not true in case of highlighted search results: they will be
injected in the DOM as `<span>` elements, causing the `<span>`s
in the text layer to have more than one child.

This patch fixes the problem by properly converting the (span, offset)
pair in a (textNode, offset) pair that points to the right text node.
@nicolo-ribaudo
Copy link
Contributor Author

/botio integrationtest

@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/9a429857156e305/output.txt

@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/e1e4d09ffad0fa6/output.txt

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Linux m4)


Failed

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

Total script time: 12.22 mins

  • Integration Tests: FAILED

@moz-tools-bot
Copy link
Collaborator

From: Bot.io (Windows)


Failed

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

Total script time: 28.17 mins

  • Integration Tests: FAILED

Copy link
Collaborator

@Snuffleupagus Snuffleupagus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r=me, thank you.

@Snuffleupagus Snuffleupagus merged commit 3cd1b10 into mozilla:master Mar 2, 2025
7 checks passed
@nicolo-ribaudo nicolo-ribaudo deleted the fix-linkannotation branch March 2, 2025 22:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Auto-linking breaks when page is scrolled into view during searching
3 participants