Skip to content

fix(renderer): hide muya float tools in source-code mode - #4732

Merged
Jocs merged 1 commit into
developfrom
fix/4731-source-mode-hide-muya-float-tools
Jun 26, 2026
Merged

Jocs merged 1 commit into
developfrom
fix/4731-source-mode-hide-muya-float-tools

Conversation

@Jocs

@Jocs Jocs commented Jun 26, 2026

Copy link
Copy Markdown
Member

Closes #4731

Summary

In source-code mode the WYSIWYG (muya) editor is only sent behind the source editor via z-index: -1 (.editor-wrapper.source) — it stays in the DOM and remains hit-testable. Four muya float tools listen on a document-level mousemove and locate the hovered block with document.elementsFromPoint(...), which returns elements regardless of z-index. So moving the mouse over the source editor found the muya block sitting underneath and re-showed muya's floating UI on top of CodeMirror:

  • paragraph front button (and the front menu it opens)
  • table drag bar
  • table column toolbar
  • preview toolbar (math / diagram blocks)

The legacy hideAllFloatTools() call on entering source mode still hides already-open floats; the gap was that they could be re-triggered by hovering — a regression of #1101.

The fix adds pointer-events: none to .editor-wrapper.source, removing the hidden editor subtree from hit-testing. document.elementsFromPoint then no longer returns the muya blocks, so none of the float tools can re-trigger. CodeMirror is a sibling of .editor-wrapper (not a descendant), so it stays fully interactive.

Type of change

  • Bug fix (non-breaking, fixes an issue)
  • New feature (non-breaking, adds functionality)
  • Breaking change (causes existing functionality to change)
  • Documentation update

Test plan

  • New unit/e2e test added — the bug is document.elementsFromPoint hit-testing behavior, which the happy-dom unit suite cannot reproduce, and the desktop e2e requires a full Electron build. A deterministic regression test belongs in test/e2e/view-modes.spec.ts (assert elementsFromPoint over the editor returns no muya block in source mode) when run against a build.
  • Verified in real Chromium (the engine Electron uses) with a faithful replica of the exact source-mode DOM hierarchy + CSS rule:
    • Before: elementsFromPoint over the editor returns the muya block (the leak) even though it sits behind CodeMirror in the hit-test stack.
    • After (pointer-events: none): the muya block is excluded, while CodeMirror is still returned (i.e. remains interactive).
  • Tested on: macOS

Notes for reviewers

  • That elementsFromPoint ignores z-index but honors pointer-events: none / visibility: hidden / display: none was confirmed empirically in Chromium.
  • pointer-events: none is the most surgical of those options — it changes neither layout, paint, nor the editor's scroll/focus state, only its hit-testability, and it fixes all four float tools at the container level rather than patching each plugin individually.

In source mode the muya editor is sent behind the source editor via
`z-index: -1` but stays in the DOM. Several muya float tools listen on a
document-level mousemove and locate the hovered block with
`document.elementsFromPoint`, which ignores z-index — so hovering over the
source editor re-triggered the paragraph front button/menu, the table
drag/column toolbars and the preview toolbar on top of CodeMirror.

Add `pointer-events: none` to `.editor-wrapper.source` so the hidden editor
subtree is excluded from hit-testing; the floats can no longer be
re-triggered, while CodeMirror (a sibling, not a descendant) stays
interactive.

Fixes #4731

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@github-actions

Copy link
Copy Markdown
Contributor

Build artifacts for PR #4732:

Run: https://github.com/marktext/marktext/actions/runs/28214822339

Artifact Size Link
marktext-windows-arm64 275.6 MB Download
marktext-linux 627.3 MB Download
marktext-windows-x64 283.8 MB Download
marktext-macos-x64 293.0 MB Download
marktext-macos-arm64 282.6 MB Download

@Jocs
Jocs merged commit 6fd3ee6 into develop Jun 26, 2026
10 checks passed
@Jocs
Jocs deleted the fix/4731-source-mode-hide-muya-float-tools branch June 26, 2026 03:51
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.

[Bug] muya UI float tools (front button, table/preview toolbars) appear in source-code mode

1 participant