Skip to content

fix(ProsePre): get code from DOM if code prop is missing#6333

Merged
benjamincanac merged 2 commits intov4from
fix/pre-copy-from-dom
Apr 11, 2026
Merged

fix(ProsePre): get code from DOM if code prop is missing#6333
benjamincanac merged 2 commits intov4from
fix/pre-copy-from-dom

Conversation

@farnabaz
Copy link
Copy Markdown
Member

🔗 Linked issue

❓ Type of change

  • 📖 Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • 👌 Enhancement (improving an existing functionality)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

📚 Description

📝 Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@farnabaz farnabaz requested a review from benjamincanac as a code owner April 10, 2026 13:30
@github-actions github-actions Bot added the v4 #4488 label Apr 10, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 10, 2026

📝 Walkthrough

Walkthrough

The Pre.vue component's copy button handler was refactored: it now calls a new copyCode() function instead of directly invoking copy(props.code || ''). copyCode() attempts to copy props.code first; if absent it falls back to the rendered <pre> element's textContent via a template ref (baseRef created using useTemplateRef), and finally uses an empty string if neither source is available. The <pre> element is bound with ref="baseRef".

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Description check ❓ Inconclusive The description is largely empty with only template content and unchecked checklist items, providing no meaningful information about the changeset despite being an enhancement. Add a description explaining why this fallback mechanism was needed and how it improves the component's functionality.
✅ Passed checks (2 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The title accurately and concisely summarizes the main change: implementing a fallback mechanism to obtain code from the DOM when the prop is missing.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/pre-copy-from-dom

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/runtime/components/prose/Pre.vue`:
- Line 75: The <pre> template in Pre.vue (the element using ref "preTemplateRef"
and class computed via ui.base with uiProp?.base and props.class) is missing the
required slot marker; add the attribute data-slot="default" (or the appropriate
slot name) to that <pre> element so it includes the slot identification per the
project's slot convention. Ensure the attribute is added to the same element
that has ref="preTemplateRef" and v-bind="$attrs" so slot tooling can detect it.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: bb7e1f7c-6648-4b82-957a-fe0cb0c4c0e8

📥 Commits

Reviewing files that changed from the base of the PR and between aae5378 and fdf7958.

📒 Files selected for processing (1)
  • src/runtime/components/prose/Pre.vue

Comment thread src/runtime/components/prose/Pre.vue Outdated
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Apr 10, 2026

npm i https://pkg.pr.new/@nuxt/ui@6333

commit: a719825

@benjamincanac benjamincanac changed the title fix(ProsePre): get code from DOM if code prop was missing fix(ProsePre): get code from DOM if code prop is missing Apr 11, 2026
@benjamincanac benjamincanac merged commit b808ce4 into v4 Apr 11, 2026
22 checks passed
@benjamincanac benjamincanac deleted the fix/pre-copy-from-dom branch April 11, 2026 11:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

v4 #4488

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants