Skip to content

Feature request: constrain hit-testing (root subtree / ignore wrappers) for embedded apps #183

@marcelocastrobarbosa

Description

@marcelocastrobarbosa

Problem

When Agentation runs inside host apps that render content inside extra wrapper <div>s (scaled canvas / artboard shells, position: absolute; inset: 0 layout layers, z-index stacking), the click handler uses document.elementFromPoint (via deepElementFromPoint). That always returns the topmost element in the browser hit-test stack.

In practice the picked node is often:

  • A transparent wrapper from the host layout (still receives hits because pointer-events defaults to auto), or
  • A full-bleed decorative layer inside a template (gradient / veil div painted above text).

The author sees the “page” or a text block, but Agentation identifies a parent shell or overlay instead. There is no public prop today to constrain hit-testing (e.g. root subtree) or to skip known host selectors, so integrators rely on fragile CSS (pointer-events: none on shells, auto only under a single template host).

Why this is not unique to one app

Any embedded preview (design tools, slide canvases, story-like layouts) with stacking contexts and wrappers will hit the same browser behaviour. It is the combination of Agentation’s pick model + typical host/template DOM.

Related issues

  • #109 — configurable / attribute-based element identity for clipboard output (same family: “what element counts?”).
  • #71 — selection constraints in other embedding contexts (iframe).

Suggested directions (API / behaviour)

  1. hitTestRootSelector (or a root ref passed from the host): from elementsFromPoint / composed path, choose the deepest HTMLElement within that root, instead of the global topmost node.
  2. hitTestIgnoreSelector (or list): treat matching elements as transparent for picking (iterate down the stack until a non-ignored target). Must be defined carefully with shadow DOM.
  3. Docs: short “Embedding Agentation” section describing recommended pointer-events layering for host shells.

Our concrete integration

React + Vite editor: slide preview under canvas transforms and editor ValidationSurface-style wrappers; without host-side CSS fixes, annotations attach to the wrapper instead of the template subtree.

Happy to help validate a design or contribute a PR if this direction matches the project’s goals.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions