CopilotKit icon indicating copy to clipboard operation
CopilotKit copied to clipboard

fix(react-core): wrap CopilotChatInput disclaimer slot in pointer-events-auto

Open jerelvelarde opened this issue 6 months ago • 4 comments

Why this matters

Every CopilotKit consumer that puts interactive content in the disclaimer slot below the input pill hits the same trap: buttons and links render but don't respond to clicks or hover. The cause isn't obvious from outside the framework — the outer input container is intentionally pointer-events: none so the absolutely-positioned input doesn't block clicks on chat messages behind it, the pill itself is re-enabled, but the disclaimer slot is a sibling that never gets re-enabled.

For a canonical starter, this is friction every customizer hits the first time they add an agent selector, model picker, or any interactive disclaimer content. They debug for 10–30 minutes, find the workaround by reading the framework source, and ship a pointerEvents: "auto" override they didn't need to know about.

image image

How it's implemented

Single-file change to packages/react-core/src/v2/components/chat/CopilotChatInput.tsx: the disclaimer render now wraps in <div className="cpk:pointer-events-auto">, mirroring the existing wrap around the input pill in the same file a few lines above.

The outer container's pointer-events: none is unchanged — pass-through over the chat column above the input continues to work as before.

Migration

Consumers who currently work around this by manually setting pointerEvents: "auto" on their disclaimer slot will see their override become a redundant no-op. No functional change for them; they can drop the override when convenient.

Known parity gap (follow-up)

Vue counterpart packages/vue/src/v2/components/chat/CopilotChatInput.vue has the same disclaimer pointer-events trap. To be addressed in a follow-up PR — left out of this scope to keep the React fix isolated.

jerelvelarde avatar May 21 '26 14:05 jerelvelarde

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
docs Ready Ready Preview, Comment May 22, 2026 8:12am

Request Review

vercel[bot] avatar May 21 '26 14:05 vercel[bot]

@jerelvelarde is attempting to deploy a commit to the CopilotKit Team on Vercel.

A member of the Team first needs to authorize it.

vercel[bot] avatar May 21 '26 14:05 vercel[bot]

Open in StackBlitz

@copilotkit/a2ui-renderer

pnpm add https://pkg.pr.new/@copilotkit/a2ui-renderer@4960

@copilotkit/agentcore-runner

pnpm add https://pkg.pr.new/@copilotkit/agentcore-runner@4960

@copilotkitnext/angular

pnpm add https://pkg.pr.new/@copilotkitnext/angular@4960

@copilotkit/core

pnpm add https://pkg.pr.new/@copilotkit/core@4960

@copilotkit/react-core

pnpm add https://pkg.pr.new/@copilotkit/react-core@4960

@copilotkit/react-native

pnpm add https://pkg.pr.new/@copilotkit/react-native@4960

@copilotkit/react-textarea

pnpm add https://pkg.pr.new/@copilotkit/react-textarea@4960

@copilotkit/react-ui

pnpm add https://pkg.pr.new/@copilotkit/react-ui@4960

@copilotkit/runtime

pnpm add https://pkg.pr.new/@copilotkit/runtime@4960

@copilotkit/runtime-client-gql

pnpm add https://pkg.pr.new/@copilotkit/runtime-client-gql@4960

@copilotkit/sdk-js

pnpm add https://pkg.pr.new/@copilotkit/sdk-js@4960

@copilotkit/shared

pnpm add https://pkg.pr.new/@copilotkit/shared@4960

@copilotkit/sqlite-runner

pnpm add https://pkg.pr.new/@copilotkit/sqlite-runner@4960

@copilotkit/voice

pnpm add https://pkg.pr.new/@copilotkit/voice@4960

@copilotkit/vue

pnpm add https://pkg.pr.new/@copilotkit/vue@4960

@copilotkit/web-inspector

pnpm add https://pkg.pr.new/@copilotkit/web-inspector@4960

commit: 4f54494

pkg-pr-new[bot] avatar May 21 '26 14:05 pkg-pr-new[bot]

Automated review

Verdict: LGTM — minor optional nit on test coverage.

Overview

Single-file fix in packages/react-core/src/v2/components/chat/CopilotChatInput.tsx (+3 / -1). The outer input container (line 1101) has cpk:pointer-events-none so it doesn't block clicks on chat messages behind the absolutely-positioned input. The input pill wrapper at line 1125 already re-enables pointer events with cpk:pointer-events-auto, but the sibling disclaimer slot at line 1128 never was — so interactive content rendered inside the disclaimer slot (agent selectors, model pickers, links) couldn't receive clicks/hover. This PR wraps {BoundDisclaimer} in a <div className="cpk:pointer-events-auto"> mirroring the existing input-pill wrapper pattern.

Correctness

  • Right shape: pointer-events-auto only re-enables inside the wrapper, preserving the outer container's pass-through over the chat column above the input.
  • Wrapper exists only on the default render path (no children prop). The render-props branch at lines 597–628 passes BoundDisclaimer through to consumers as a slot, so headless consumers retain full control — consistent with how outer pointer events are handled.
  • shouldShowDisclaimer (line 595) gates rendering, so no empty wrapper div is added when nothing is shown.
  • Consumers currently overriding pointerEvents: "auto" inline (per PR description) will see their override become a redundant no-op — no regression.

Style / Conventions

  • Uses the cpk: Tailwind prefix consistently.
  • Pattern mirrors the input-pill wrapper directly above (line 1125), which is the correct reference. Visual symmetry makes the relationship discoverable.
  • No new exports, no API surface changes, no breaking changes.

Test coverage

  • Existing disclaimer tests in packages/react-core/src/v2/components/chat/__tests__/CopilotChatInput.slots.e2e.test.tsx lines 836–928 cover render presence/absence and class application but do not assert pointer-events on the wrapper. Optional regression assertion (cheap insurance against future JSX refactors):
    const wrapper = container.querySelector('.cpk\\:pointer-events-auto');
    expect(wrapper).not.toBeNull();
    
    Scoped to the disclaimer container. Not blocking — the visual symmetry with the pill wrapper makes accidental removal unlikely, and asserting compiled Tailwind pointer-events: auto through jsdom is awkward.

Risks / edge cases

  • None on the default render path. The change is additive and scoped to one conditional branch.
  • Headless children-prop consumers are unaffected (they manage their own pointer events around the disclaimer slot — consistent with the existing slot contract).
  • A custom disclaimer component that internally relies on pointer-events: none (very unlikely) could see its inner pointer behavior shadowed; child elements can still opt out with their own pointer-events: none, so the escape hatch remains.

Performance / Security

No impact on either. One extra div in the tree only when the disclaimer is shown.

jerelvelarde avatar May 22 '26 07:05 jerelvelarde