Skip to content

feat: restrict view-mode click activation to block content (not margins) #221

@oobagi

Description

@oobagi

Problem

In view mode, clicking anywhere on a block's rendered Y-row activates it — including horizontal margin areas outside the block's actual content. This leads to accidental checklist toggles and embed-block opens when a user is just clicking around to focus the terminal or select text.

Context

  • Click handling lives in internal/editor/editor.go:1510 (tea.MouseClickMsg case), with view-mode branch at line 1538.
  • Block lookup uses m.blockIndexAtLine(hoverY) (line 1541) which maps a Y coordinate to a block but does not check X. Any X within the terminal width on that row resolves to the block.
  • Clickable blocks in view mode today: Checklist (toggle at line 1546), Embed (open at line 1558). Definition hyperlinks (Definition hyperlinks in text #211) likely add more.

Approach

Two options — the issue is asking to pick one:

Option A — Margin guard (recommended default). Compute each block's actual rendered content X-range (respecting centered view-mode layout, padding, indent). Only activate the click if msg.X falls inside that range. This is the least-surprising behavior and doesn't require user configuration.

Option B — Config toggle disable_clickable_items. Add a bool config + runtime toggle that turns off click activation entirely in view mode. Useful for users who just want read-only no-interaction view mode.

Recommend doing A first (fixes the main complaint), and optionally adding B later if users still want full opt-out.

Tasks

  • Expose (or compute on demand) the content X-range for each rendered block in view mode. View mode centers content, so the range depends on terminal width and content width.
  • In the MouseClickMsg view-mode branch, bail out early if msg.X is outside the content range.
  • Preserve existing hover behavior (hover visual feedback can stay row-wide, or also be narrowed — decide).
  • (Optional) Add disable_clickable_items config with a runtime toggle.
  • Tests: clicks in margin don't toggle; clicks on content still toggle; centered layout boundaries correct at narrow/wide widths.

Acceptance criteria

  • Clicking in the left/right margin of a checklist block does NOT toggle it.
  • Clicking on the actual checklist text/box still toggles it.
  • Same guard applies to embed blocks and any other view-mode-clickable types.
  • No regression in hover highlight behavior (or deliberate, documented change).

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions