Skip to content

Fix term popup not showing for uppercase terms - #4494

Merged
flodolo merged 2 commits into
mozilla:mainfrom
baha-bouali:fix-uppercase-term-popup
Sep 4, 2026
Merged

Fix term popup not showing for uppercase terms#4494
flodolo merged 2 commits into
mozilla:mainfrom
baha-bouali:fix-uppercase-term-popup

Conversation

@baha-bouali

Copy link
Copy Markdown
Contributor

Fixes #4474

Problem

Clicking a term in the source string did nothing when the term was stored with an uppercase first letter in the terminology database.

Cause

Highlight.tsx writes the term's stored text into data-match on the <mark> element. The click handler in OriginalString.tsx then looked it up with:

terms.terms?.filter((t) => t.text.toLowerCase() === markedTerm)

Only the left side was lowercased, so a term stored as Issue produced "issue" === "Issue". This resulted in no match, empty result, no popup. Terms stored lowercase were unaffected, which is why the failure only showed on capitalized entries.

Fix

Lowercase both sides of the comparison.

Testing

Created two local terms, one stored capitalized and one lowercase, each with a definition and an Arabic translation. Before the change, only the lowercase term opened its popup; after, both do.

Visual proof:

PR1.Pontoon.webm

@baha-bouali

Copy link
Copy Markdown
Contributor Author

cc @flodolo

@flodolo flodolo left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Great job with the PR. The fix works, just need to fix formatting with prettier.

@baha-bouali

Copy link
Copy Markdown
Contributor Author

Thanks! Fixed formatting with npm run prettier.
btw, and unrelated to this fix, I noticed that Hightlight.tsx:115 applies term regex using [a-zA-z]* rather than [a-zA-Z]*, which includes non-alphabetical characters. Was this intentional? Thanks!

@flodolo

flodolo commented Sep 4, 2026

Copy link
Copy Markdown
Collaborator

btw, and unrelated to this fix, I noticed that Hightlight.tsx:115 applies term regex using [a-zA-z]* rather than [a-zA-Z]*, which includes non-alphabetical characters. Was this intentional? Thanks!

I'll check with @eemeli, but feels like a typo (from #3014)

const re = new RegExp(`\\b${escapeRegExp(term)}[a-zA-z]*\\b`, 'gi');

@flodolo

flodolo commented Sep 4, 2026

Copy link
Copy Markdown
Collaborator

Will file an issue for the regex, since it's indeed a typo.

Welcome to Pontoon. We also have a Matrix channel if you want to join
https://chat.mozilla.org/#/room/#pontoon:mozilla.org

@flodolo
flodolo merged commit c47db3e into mozilla:main Sep 4, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

For uppercase terms, clicking in the source doesn't show definition in pop-up

2 participants