Skip to content

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

Open
LoukasPap wants to merge 2 commits 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 2 commits 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.41%. Comparing base (5b100c4) to head (b441120).
⚠️ Report is 9 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.40%   89.41%           
=======================================
  Files         262      262           
  Lines       66762    66748   -14     
=======================================
- Hits        59690    59683    -7     
+ Misses       7072     7065    -7     
Flag Coverage Δ
browsertest 66.51% <0.00%> (-0.01%) ⬇️
fonttest 9.05% <ø> (+<0.01%) ⬆️
integrationtest 68.74% <75.00%> (+0.02%) ⬆️
unittest 57.32% <0.00%> (-0.02%) ⬇️
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!

});
});

describe("Show all disabled status must be persistence", () => {

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.

Nit: s/persistence/persistent

)
.toBe(true);

const visibilityState = await page.evaluate(selector => {

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.

It looks like we can just call this const hasHiddenClass and then return a boolean value instead of an object with just a single property, which overall seems simpler.

The same applies to the test below that has a similar pattern.

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

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.

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