Skip to content

Fix false enable of highlights when opening the editor menu#21535

Open
LoukasPap wants to merge 1 commit into
mozilla:masterfrom
LoukasPap:fix/false-enable-of-highlights
Open

Fix false enable of highlights when opening the editor menu#21535
LoukasPap wants to merge 1 commit into
mozilla:masterfrom
LoukasPap:fix/false-enable-of-highlights

Conversation

@LoukasPap

Copy link
Copy Markdown

Fixes #21498

The fix ensures that the "Show all" toggle button remains consistent across updates in editor mode and it reflects the correct highlight state (even if we highlight from floating toolbar).

The two integration tests cover the following cases:

Test 1

  1. Open highlight editor
  2. Highlight text ("Abstract")
  3. Click "Show all" toggle to disable (hide highlights)
  4. Close highlight editor
  5. Open ink editor
  6. Switch to highlight editor
  7. Assert: Show all button is still disabled (aria-pressed="false")
  8. Assert: Highlight remains hidden

Test 2

  1. Open highlight editor
  2. Highlight text ("Abstract")
  3. Click "Show all" toggle to disable (hide highlights)
  4. Close highlight editor
  5. Double-click to select text
  6. Highlight it from floating toolbar
  7. Close highlight editor
  8. Re-open highlight editor
  9. Assert: Show All is still disabled (aria-pressed="false")
  10. Assert: Highlight is still hidden

Comment thread test/integration/highlight_editor_spec.mjs Outdated
@codecov-commenter

codecov-commenter commented Jul 4, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 89.73%. Comparing base (8bc2fe6) to head (a7645cc).
⚠️ Report is 8 commits behind head on master.

Files with missing lines Patch % Lines
src/display/editor/tools.js 75.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #21535      +/-   ##
==========================================
+ Coverage   89.71%   89.73%   +0.01%     
==========================================
  Files         262      262              
  Lines       66709    66713       +4     
==========================================
+ Hits        59847    59863      +16     
+ Misses       6862     6850      -12     
Flag Coverage Δ
browsertest 66.55% <0.00%> (-0.01%) ⬇️
fonttest 9.05% <ø> (ø)
integrationtest 69.26% <75.00%> (+0.01%) ⬆️
unittest 57.32% <0.00%> (-0.01%) ⬇️
unittestcli 56.28% <0.00%> (-0.01%) ⬇️

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

☔ View full report in Codecov by Harness.
📢 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.

@timvandermeij timvandermeij 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.

Code-wise this patch LGTM with the comments addressed, but I'd prefer @calixteman also review this to given his familiarity with this particular code.

After addressing the review comments, please keep the commits squashed into one; see https://github.com/mozilla/pdf.js/wiki/Squashing-Commits if you're not familiar with how to do that.

Thank you for your contribution!

Comment thread test/integration/highlight_editor_spec.mjs Outdated
Comment thread test/integration/highlight_editor_spec.mjs Outdated
@LoukasPap

Copy link
Copy Markdown
Author

I'll wait for @calixteman to see the PR too and address all issues together (and then squash). Thank you for reviewing!


await page.waitForSelector(".editToolbar");
const highlightFromToolbar = await page.$(
".floatingToolbar button[data-action='highlight']"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is it an AI hallucination ?
.floatingToolbar exists only in the geckoview and is unrelated to highlighting.

@LoukasPap LoukasPap Jul 9, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I sometimes called it floatingToolbar having seen it in editor/toolbar.js:

class FloatingToolbar {

Changed it to .editToolbar

const highlightFromToolbar = await page.$(
".floatingToolbar button[data-action='highlight']"
);
if (highlightFromToolbar) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't understand this check by itself... except that it's fixing the floatingToolbar mentioned issue.
So this code is just dead code.

@LoukasPap LoukasPap Jul 9, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

The code locates the highlight button from the editToolbar (or floatingToolbar) and verifies it exists. If for example after selecting a text, the editToolbar hadn't show up for a reason, then the highlightFromToolbar button would not exist.

We could rename it to editToolbarHighlightBtn to be more clear.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It must show up, if it didn't then something is wrong in your test.
You can wait for having it visible and then get it.

@LoukasPap
LoukasPap force-pushed the fix/false-enable-of-highlights branch from b441120 to a7645cc Compare July 9, 2026 15:54
@LoukasPap
LoukasPap requested a review from calixteman July 9, 2026 15:54
@LoukasPap

Copy link
Copy Markdown
Author

@calixteman I applied the changes discussed

layer.updateMode(mode);
}

const highlightShowAllState = this.#showAllStates?.get(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't think it's enough in general.
With tracemonkey.pdf, you can

  • highlight on the 1st page
  • scroll and highlight on the last one
  • scroll back to the first
  • hide the highlights
  • turn off the highlight mode
  • turn it on
  • scroll to the last page.

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]: Opening editor toolbar falsely enables hidden highlights

4 participants