Skip to content

Fix CopyPromptButton crashing when rendered with no props - #513

Merged
dprevoznik merged 1 commit into
mainfrom
hypeship/fix-copy-prompt-button-null-props
Aug 21, 2026
Merged

Fix CopyPromptButton crashing when rendered with no props#513
dprevoznik merged 1 commit into
mainfrom
hypeship/fix-copy-prompt-button-null-props

Conversation

@dprevoznik

@dprevoznik dprevoznik commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Summary

  • The homepage's fast setup copy-prompt button disappeared after Add Foreman integration guide to Vercel section #510 refactored CopyPromptButton to accept optional prompt/label props for reuse on the new Foreman page.
  • <CopyPromptButton /> with no attributes renders with null props under the classic JSX transform. Destructured parameter defaults ({ prompt = X } = {}) only apply when the argument is undefined, not null, so the no-props call throws and the component renders empty.
  • foreman.mdx always passes an explicit prompt object, so that usage was unaffected — only the homepage broke.

Fix: destructure prompt/label from props || {} inside the function body instead of relying on a parameter-level default, so both null and undefined fall back correctly.

Test plan

  • Reproduced the exact failure in a Node harness: the old signature throws on Component(null); the new one returns the correct defaults for null, undefined, and a real props object.
  • Confirmed via a live browser session against kernel.sh/docs that the homepage button currently renders as an empty <div> with no console errors, consistent with a swallowed render-time exception rather than a network/asset failure.
  • Could not run mintlify dev in this sandbox to visually confirm the button reappears (matches the constraint noted in Add Foreman integration guide to Vercel section #510).

Note

Low Risk
Tiny UI-only defaulting change in a docs snippet; no auth, data, or API impact.

Overview
Fixes the homepage copy-prompt button disappearing when rendered as <CopyPromptButton /> with no attributes.

Classic JSX can pass null props, so parameter defaults ({ prompt = … } = {}) never ran and destructuring threw. Defaults are now taken from props || {} so null and undefined both fall back to DEFAULT_PROMPT and the default label.

Reviewed by Cursor Bugbot for commit e46d02c. Bugbot is set up for automated code reviews on this repo. Configure here.

<CopyPromptButton /> with no attributes passes null props under the
classic JSX transform, and destructuring defaults only apply to
undefined, not null, so the homepage's default-prompt usage broke
while the parameterized usage on the Foreman page kept working.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Risk assessment: Very Low

Verdict: Approve.

What changed

A two-line fix in snippets/copy-prompt-button.jsx. The component now reads prompt/label from props || {} instead of destructuring in the parameter list with = {}. Callers that pass a real props object are unchanged. Callers that pass null (classic JSX with no attributes) no longer throw on destructure and fall back to the existing defaults.

DEFAULT_PROMPT text is not modified. The only other usages are <CopyPromptButton /> on the docs homepage and an explicit prompt={...} on the Foreman page.

Why this is Very Low

  • Scope: 1 file, +2/−1. Docs-site snippet only.
  • Blast radius: Restores the intended no-props render path. Explicit-prop usage is unaffected.
  • Infra / security: No auth, permissions, APIs, schema, or infrastructure.
  • Prompts: The LLM prompt string in this file is unchanged; this is a JS defaulting fix, not a prompt edit.
  • Correctness: null and undefined both get the same defaults. Easy to reason about.

No CODEOWNERS file, and this PR has no prior reviews or approvals.

Open in Web View Automation 

Sent by Cursor Automation: Assign PR reviewers

@dprevoznik
dprevoznik merged commit d16f185 into main Aug 21, 2026
3 checks passed
@dprevoznik
dprevoznik deleted the hypeship/fix-copy-prompt-button-null-props branch August 21, 2026 16:26
@mintlify

mintlify Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
Kernel 🔴 Failed Aug 21, 2026, 6:19 PM

💡 Tip: Enable Workflows to automatically generate PRs for you.

dprevoznik added a commit that referenced this pull request Aug 21, 2026
#510 hoisted the homepage's default prompt text into a module-level
DEFAULT_PROMPT const so the Foreman page could override it via props.
That constant doesn't resolve in Mintlify's per-page render (Reference
Error: DEFAULT_PROMPT is not defined), breaking the homepage button.
#513 patched the destructuring but never touched DEFAULT_PROMPT's
scope, so the underlying failure was still live.

Move the default prompt text back inside the function body, matching
how it worked before #510, while keeping the prompt/label override
for the Foreman page.
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