Skip to content

Move editToolbar and fix overlapping annotations with it - #21723

Open
LoukasPap wants to merge 1 commit into
mozilla:masterfrom
LoukasPap:fix/link-overlaps-floating-toolbar
Open

LoukasPap wants to merge 1 commit into
mozilla:masterfrom
LoukasPap:fix/link-overlaps-floating-toolbar

Conversation

@LoukasPap

@LoukasPap LoukasPap commented Aug 6, 2026 •

Copy link
Copy Markdown

Fixes #21643

I moved the editToolbar up to page level and added isolation: isolate to .annotationLayer, .annotationEditorLayer and .editor toolbar elements so that z-index works at their level. That way we avoid the z-index of a nested annotation (e.g. a linkAnnotation) "compete" with the z-index of the editToolbar.

This PR also fixes a bug where a textAnnotation was rendered above the editToolbar.

Tests

I used document.elementFromPoint(x,y) to check every time which elements is rendered on top.
I also moved createFreeTextEditor() to test_utils.mjs to make it available to all tests that may need it

Test 1 — "the edit toolbar is rendered above link annotations"

  1. Load the PDF at 120% zoom, wait for the text layer to be ready.
  2. Find the link pointing to https://github.com/mozilla/pdf.js and get its position.
  3. Check what's on top at that spot right now — confirm it's the link itself (pdfjs_internal_id_14R), i.e. nothing is covering it yet.
  4. Double-click on "A:" to select it, which makes the floating toolbar appear.
  5. Wait for the toolbar's highlight button to show up.
  6. Check what's on top at the link's position again — confirm it's now the highlight button, proving the toolbar renders above the link instead of being hidden behind it.

Test 2 — "the edit toolbar is rendered above text annotations"

  1. Switch into FreeText editing mode.
  2. Find "My text" on the page and note its position.
  3. Create a new text annotation containing "CHECK", placed just below "My text".
  4. Check what's on top at the middle of that new "CHECK" box — confirm it's the text annotation itself (its own edit toolbar/label), i.e. nothing else is covering it yet.
  5. Close the text editor (exit FreeText mode).
  6. Double-click on "My text" to select it, which makes the floating toolbar appear.
  7. Wait for the toolbar's highlight button to show up.
  8. Check what's on top at the toolbar's position — confirm it's the highlight button.
  9. Re-open the text editor (re-enter FreeText mode) without closing the floating toolbar, so both are visible on the page at the same time.
  10. Check what's on top at the freetext's position — confirm it's still the highlight button, proving the toolbar stays rendered above the reopened text annotation rather than getting covered by it.

@LoukasPap LoukasPap changed the title Fix link overlapping floating toolbar Move editToolbar and fix overlapping annotations with it Aug 6, 2026
@LoukasPap
LoukasPap marked this pull request as draft August 6, 2026 20:49
@LoukasPap

Copy link
Copy Markdown
Author

This is currently a draft because I haven't yet added the integration tests. I pushed anyway to make sure we agree with the solution and then move on.

@LoukasPap
LoukasPap force-pushed the fix/link-overlaps-floating-toolbar branch 2 times, most recently from 7c9c34c to c48cbd1 Compare August 6, 2026 20:58
@LoukasPap
LoukasPap force-pushed the fix/link-overlaps-floating-toolbar branch 2 times, most recently from f1d551a to 356901b Compare August 19, 2026 16:01
@LoukasPap
LoukasPap marked this pull request as ready for review August 19, 2026 16:03
@codecov-commenter

codecov-commenter commented Aug 20, 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 90.31%. Comparing base (15c9dc8) to head (9801a3a).
⚠️ Report is 696 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   #21723      +/-   ##
==========================================
- Coverage   90.31%   90.31%   -0.01%     
==========================================
  Files         269      269              
  Lines       67542    67545       +3     
==========================================
+ Hits        61000    61001       +1     
- Misses       6542     6544       +2     
Flag Coverage Δ
browsertest 66.15% <0.00%> (+<0.01%) ⬆️
fonttest 8.94% <ø> (ø)
integrationtest 69.35% <75.00%> (+<0.01%) ⬆️
unittest 59.50% <0.00%> (-0.02%) ⬇️
unittestcli 57.99% <0.00%> (-0.03%) ⬇️

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.

@LoukasPap

LoukasPap commented Aug 29, 2026 •

Copy link
Copy Markdown
Author

I'll squash and do the final push if PR is ok.

Comment thread test/integration/test_utils.mjs Resolved
Comment thread test/test_manifest.json Resolved
@LoukasPap
LoukasPap force-pushed the fix/link-overlaps-floating-toolbar branch from 631237b to 0067ba1 Compare September 7, 2026 16:23
@timvandermeij

Copy link
Copy Markdown
Collaborator

/botio-linux preview

@moz-tools-bot

Copy link
Copy Markdown
Collaborator

@LoukasPap

Copy link
Copy Markdown
Author

The failing test is flaky.

@LoukasPap

Copy link
Copy Markdown
Author

I have resolved the conflicts but don't push yet in case @calixteman asks for changes.

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

Looks good to me, with the final comments addressed. This seems to work just fine in the viewer, but given his familiarity with this code I'd prefer @calixteman to give the final approval here. Thank you for your contribution!

});
});

describe("editToolbar is rendering over annotations", () => {

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.

This is not for this PR, but in a follow-up we might want to consider moving the floating toolbar tests into their own spec. It feels a bit odd conceptually to have it here because we don't create actual highlight annotations in these tests, nor is the floating toolbar only for highlight annotations as comments can also be created with it now. (It originally used to only be for highlighting, and the preference name is also called that, but I think that predates the commenting addition.)

@calixteman What do you think?

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.

Agreed.

@LoukasPap
LoukasPap force-pushed the fix/link-overlaps-floating-toolbar branch from 0067ba1 to 9801a3a Compare September 13, 2026 14:32
@LoukasPap

LoukasPap commented Sep 30, 2026 •

Copy link
Copy Markdown
Author

Any update on this? @calixteman

This branch was previously deployed

1 inactive (outdated) deployment
code-coverage — 631237bd Deployed Aug 28, 2026 by LoukasPap via windows-latest / chrome #1427
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]: Overlapping annotations can be clicked through editor toolbar

5 participants