Fix CopyPromptButton crashing when rendered with no props - #513
Conversation
<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.
There was a problem hiding this comment.
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:
nullandundefinedboth get the same defaults. Easy to reason about.
No CODEOWNERS file, and this PR has no prior reviews or approvals.
Sent by Cursor Automation: Assign PR reviewers
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Workflows to automatically generate PRs for you. |
#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.


Summary
fast setupcopy-prompt button disappeared after Add Foreman integration guide to Vercel section #510 refactoredCopyPromptButtonto accept optionalprompt/labelprops for reuse on the new Foreman page.<CopyPromptButton />with no attributes renders withnullprops under the classic JSX transform. Destructured parameter defaults ({ prompt = X } = {}) only apply when the argument isundefined, notnull, so the no-props call throws and the component renders empty.foreman.mdxalways passes an explicitpromptobject, so that usage was unaffected — only the homepage broke.Fix: destructure
prompt/labelfromprops || {}inside the function body instead of relying on a parameter-level default, so bothnullandundefinedfall back correctly.Test plan
Component(null); the new one returns the correct defaults fornull,undefined, and a real props object.<div>with no console errors, consistent with a swallowed render-time exception rather than a network/asset failure.mintlify devin 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
nullprops, so parameter defaults ({ prompt = … } = {}) never ran and destructuring threw. Defaults are now taken fromprops || {}sonullandundefinedboth fall back toDEFAULT_PROMPTand the default label.Reviewed by Cursor Bugbot for commit e46d02c. Bugbot is set up for automated code reviews on this repo. Configure here.