Skip to content

fix(Separator): forward fall-through attributes to root#6641

Merged
benjamincanac merged 5 commits into
v4from
fix/separator-fallthrough-attrs
Jun 26, 2026
Merged

fix(Separator): forward fall-through attributes to root#6641
benjamincanac merged 5 commits into
v4from
fix/separator-fallthrough-attrs

Conversation

@benjamincanac

@benjamincanac benjamincanac commented Jun 26, 2026

Copy link
Copy Markdown
Member

🔗 Linked issue

Resolves #6611

❓ Type of change

  • 🐞 Bug fix (a non-breaking change that fixes an issue)

📚 Description

AuthForm emitted a [Vue warn]: Extraneous non-props attributes (data-slot)… warning whenever both fields and providers were present (i.e. when a Separator is rendered between them).

The root cause is in Separator, not AuthForm. #6415 introduced createReusableTemplate, which placed <DefineContainer> as a sibling root node of <Separator>. That turned Separator into a multi-root (fragment) component, and fragment components can't automatically inherit fall-through attributes — so the data-slot="separator" that AuthForm passes (consistent with how it tags every other child, e.g. data-slot="input") could no longer be applied, producing the warning.

The fix follows the pattern already used by the other multi-root components in the codebase (Header, Sidebar, PricingPlan, Table, FileUpload, NavigationMenu):

  • defineOptions({ inheritAttrs: false })
  • forward attributes explicitly on the real root via v-bind="{ ...rootProps, ...$attrs }"

This restores attribute forwarding to the <Separator> root for any fall-through attribute (id, aria-*, events, data-*), with no change to the rendered DOM (no snapshot changes).

📝 Checklist

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

`createReusableTemplate` placed `DefineContainer` as a sibling root node,
turning Separator into a multi-root component that can no longer
auto-inherit fall-through attributes. Passing one (e.g. `data-slot` from
`AuthForm` when both `fields` and `providers` are present) triggered a
Vue "Extraneous non-props attributes" warning.

Set `inheritAttrs: false` and forward `$attrs` explicitly to the root,
matching the pattern used by the other multi-root components.
@github-actions github-actions Bot added the v4 #4488 label Jun 26, 2026
@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Separator.vue now disables automatic attribute inheritance and explicitly forwards remaining attributes together with rootProps to the root Separator child. Separator.spec.ts adds a test that mounts the component with extra attributes, verifies they appear on the rendered root element, and checks that no extraneous non-props warning is logged.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: forwarding fall-through attributes in Separator.
Linked Issues check ✅ Passed The change addresses #6611 by forwarding attrs from Separator and removing the extraneous non-props warning.
Out of Scope Changes check ✅ Passed The PR stays focused on Separator attribute inheritance and its regression test, with no obvious unrelated changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description check ✅ Passed The description directly matches the Separator attribute-forwarding fix and the added regression test.
✨ 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/separator-fallthrough-attrs

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/runtime/components/Separator.vue`:
- Line 107: Caller-provided data-slot is being overwritten by the Separator root
element because the static data-slot attribute wins over the v-bound attrs
spread. Update the Separator component’s root binding so the default "root"
value is applied inside the v-bind object rather than as a static attribute,
preserving any consumer-supplied $attrs data-slot while still falling back to
"root". Use the Separator template/root element and its existing
rootProps/$attrs merge as the place to fix this.

In `@test/components/Separator.spec.ts`:
- Around line 29-45: The Separator.spec.ts test that spies on console.warn
should always restore the spy in a finally block so failures in mountSuspended,
wrapper.get, or assertions do not leak the mock into later tests. Update the
test around the warn spy in the “forwards fall-through attributes to the root
without warning” case to wrap the assertions in try/finally and call
warn.mockRestore() in the finally path.
🪄 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: 1700b63a-a67a-4dc0-ab12-7cfb26753474

📥 Commits

Reviewing files that changed from the base of the PR and between 09fb52b and 0fcec44.

📒 Files selected for processing (2)
  • src/runtime/components/Separator.vue
  • test/components/Separator.spec.ts

Comment thread src/runtime/components/Separator.vue
Comment thread test/components/Separator.spec.ts Outdated
@pkg-pr-new

pkg-pr-new Bot commented Jun 26, 2026

Copy link
Copy Markdown
npm i https://pkg.pr.new/@nuxt/ui@6641

commit: f866a27

… finally

Apply the default `data-slot="root"` inside the v-bind object so a
consumer-supplied `$attrs['data-slot']` (e.g. AuthForm's "separator")
takes precedence instead of being overwritten by the static attribute.

Also wrap the fall-through test assertions in try/finally so the
`console.warn` spy is always restored.
Revert the caller-supplied data-slot preservation. `data-slot` precedence
is an inconsistency across the whole library (some components honor the
caller, others force "root" or drop it) and is purely cosmetic since
styling flows through the `class` prop. It will be addressed consistently
in a dedicated PR. This keeps #6611 scoped to the actual fix: the
multi-root fall-through warning.

The try/finally test hygiene fix is retained.
@benjamincanac benjamincanac merged commit 88baabc into v4 Jun 26, 2026
24 checks passed
@benjamincanac benjamincanac deleted the fix/separator-fallthrough-attrs branch June 26, 2026 15:38
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.

AuthForm causes "extraneous non-props attributes" warning when providers AND fields are present

1 participant