Skip to content

Deep-select / pierce overlays (modifier-hold)#25

Merged
raimannma merged 1 commit into
mainfrom
deep-select-pierce
Jun 30, 2026
Merged

Deep-select / pierce overlays (modifier-hold)#25
raimannma merged 1 commit into
mainfrom
deep-select-pierce

Conversation

@raimannma

Copy link
Copy Markdown
Owner

What

Hold the primary modifier (Cmd on Mac, Ctrl on Win/Linux) while hovering to pierce through invisible overlays, empty wrapper containers, and opacity:0 animation ghosts, highlighting the real content element underneath. The existing highlight is shown on the pierced target with a dashed border. Useful for annotating animation-heavy UIs (Framer Motion, Remotion, etc.) where overlay divs intercept the pointer.

Reimplements upstream benjitaylor#119 (concept by @stevysmith).

How

  • package/src/utils/element-identification.ts: pure, unit-tested helpers
    • hasDirectTextContent(el) — element renders its own (non-whitespace) text node.
    • resolvePierceTarget(candidates) — from the elementsFromPoint stack pick: (1) topmost visible element with direct text, (2) else smallest visible box (catches text-less visual elements like swatches/bars), (3) else topmost.
  • package/src/components/page-toolbar-css/index.tsx:
    • pierceElementFromPoint / isElementPaintable wire the resolver to the live DOM, reusing the existing iframe-aware elementsFromPointWithIframes and native checkVisibility().
    • Hover handler is opt-in: default hover still uses deepElementFromPoint and is unchanged. The dashed indicator appears only when piercing actually changes the target. Pressing/releasing the modifier re-resolves the current point without a mouse move.

Cherry-pick vs reimplement

Reimplemented. The upstream patch was rewritten against this fork's current code:

  • Dropped upstream's global identifyElement text-preference change — kept the default class-name vs text heuristic untouched (pierce only changes which element is targeted), per the package's UI-scrutiny constraints.
  • Reused this fork's elementsFromPointWithIframes instead of bare elementsFromPoint.
  • Moved resolution into a pure helper with unit tests instead of inline DOM scanning.
  • Omitted the upstream demo/website files to keep published-package code minimal.

Behavior change to flag for maintainer

The fork's multi-select gesture is modifier+CLICK (no Shift); pierce is modifier+HOVER. Since the modifier is already held during a multi-select click, that click now resolves to the pierced element rather than the topmost overlay — so "hold modifier, hover (pierce), click" selects the element the dashed highlight showed. For points with no overlay this is identical to the previous behavior.

Build / test

  • pnpm build — success (DTS type-check included; only pre-existing SCSS deprecation warnings).
  • pnpm --filter agentation test — 111 passed (11 new tests for the pierce resolver / hasDirectTextContent).

🤖 Generated with Claude Code

Holding the primary modifier (Cmd on Mac, Ctrl on Win/Linux) while hovering
now pierces through invisible overlays, empty wrapper containers, and
opacity:0 animation ghosts to highlight the real content element underneath.
This helps annotating animation-heavy frameworks (Framer Motion, Remotion,
etc.) where overlay divs intercept the pointer.

- resolvePierceTarget + hasDirectTextContent helpers in element-identification.ts
  resolve the real target from the full elementsFromPoint stack: topmost visible
  element with direct text, else smallest visible box, else topmost.
- pierceElementFromPoint / isElementPaintable wire the resolver to the live DOM
  (reusing the existing elementsFromPointWithIframes + checkVisibility).
- The hover handler is opt-in: default hover still uses deepElementFromPoint and
  is unchanged. Pierce is flagged only when it actually changes the target, and
  the highlight switches to a dashed border. Pressing/releasing the modifier
  re-resolves the current point without a mouse move.
- The default element-identification heuristic (class-name vs text) is left
  untouched; piercing only changes which element is targeted.

Reconciliation with the existing modifier-CLICK multi-select gesture: pierce is
modifier-HOVER, multi-select is modifier-CLICK. Since the modifier is already
held during a multi-select click, that click now resolves to the pierced
element, so "hold modifier, hover (pierce), click" selects the element the
dashed highlight showed.

Reimplemented (not cherry-picked) from upstream benjitaylor#119:
the upstream patch was rewritten against this fork's current code, dropped its
global identifyElement text-preference change (kept opt-in per scrutiny
constraints), reused this fork's iframe-aware elementsFromPointWithIframes, and
moved the resolution into a pure, unit-tested helper. Demo/website files were
omitted to keep published-package code minimal.

Concept by @stevysmith.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@raimannma raimannma self-assigned this Jun 30, 2026
@raimannma raimannma merged commit 32ae0bd into main Jun 30, 2026
@raimannma raimannma deleted the deep-select-pierce branch June 30, 2026 13:22
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.

1 participant