Skip to content

fix: exclude toolbar and status bar from Select All - #30

Open
FrankLedo wants to merge 1 commit into
ptheofan:mainfrom
FrankLedo:fix/select-all-excludes-chrome
Open

fix: exclude toolbar and status bar from Select All#30
FrankLedo wants to merge 1 commit into
ptheofan:mainfrom
FrankLedo:fix/select-all-excludes-chrome

Conversation

@FrankLedo

Copy link
Copy Markdown

Fixes #29.

Problem

Cmd+A selects the toolbar and status bar text along with the document, so copying afterwards puts app chrome in the clipboard.

{ role: 'selectAll' } (src/main/menu/applicationMenu.ts:79) is Electron's native role — it dispatches Blink's SelectAll across the whole document, and the chrome lives in the same document as the rendered markdown (index.html).

Before the fix, the serialized selection was:

Open\n\n\n\nEdit\n\n\n\nSample Heading\nBody paragraph text.\n\nNo file\n100%\nNot watching

Fix

Extends the user-select: none treatment already on .file-name (src/index.css:191) to the .toolbar and .status-bar containers. That .file-name rule is why "No file open" was already absent from the selection above while "Open" and "Edit" were not — the mechanism was already in the codebase, just not applied to the containers.

I deliberately kept this in CSS rather than replacing the menu role with a custom handler scoped to #markdown-content. A custom handler would break native Cmd+A inside text inputs — notably the find bar, which mounts into #markdown-viewer (src/renderer.ts:182). The CSS approach leaves native selection semantics intact everywhere.

Tests

Adds tests/e2e/select-all.spec.ts, driving the same Blink command the menu role dispatches and asserting on the serialized selection: content is still selected, chrome is not. All three fail on main and pass with the fix.

Verified locally on macOS (arm64):

  • e2e: 25/25 passed
  • unit: 598/598 passed, no type errors
  • npm run lint: clean

Note for maintainer

Two things I hit that are outside this PR's scope:

  • The find bar mounts inside #markdown-viewer, so its text is also caught by Select All while it is open. Same class of issue, separate fix — happy to open a follow-up if you want it.
  • npm ci left node_modules/electron without a complete dist/ (missing Contents/Frameworks) and no path.txt, so electron.launch failed until I re-extracted the cached zip with ditto. May overlap with what Fix build environment and link handling for both internal anchors and links to local documents #28 is addressing.

Cmd+A uses Electron's native `selectAll` role, which dispatches Blink's
SelectAll command across the entire document. The toolbar and status bar
live in the same document as the rendered markdown, so their text was
selected and copied along with the document content.

Extends the `user-select: none` treatment already applied to `.file-name`
to the `.toolbar` and `.status-bar` containers. Keeping this in CSS rather
than replacing the menu role preserves native Cmd+A behaviour inside text
inputs such as the find bar.

Adds e2e coverage driving the same Blink command the menu role dispatches.

Fixes ptheofan#29
@FrankLedo
FrankLedo marked this pull request as ready for review July 20, 2026 19:02
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.

Cmd-A selects toolbar/status bar text along with document content

1 participant