Skip to content

refactor(components): [badge/breadcrumb/button] use type-based definitions#23414

Merged
btea merged 15 commits into
element-plus:devfrom
snowbitx:refactor/use-type-bases
Jan 18, 2026
Merged

refactor(components): [badge/breadcrumb/button] use type-based definitions#23414
btea merged 15 commits into
element-plus:devfrom
snowbitx:refactor/use-type-bases

Conversation

@snowbitx
Copy link
Copy Markdown
Contributor

@snowbitx snowbitx commented Jan 17, 2026

Please make sure these boxes are checked before submitting your PR, thank you!

  • Make sure you follow contributing guide English | (中文 | Español | Français).
  • Make sure you are merging your commits to dev branch.
  • Add some descriptions and refer to relative issues for your PR.

ref:#23399. badge & breadcrumb / breadcrumb-item & button / button-group

Summary by CodeRabbit

  • Refactor

    • Strengthened public TypeScript interfaces across Badge, Breadcrumb, Button, and ButtonGroup; components now use explicit typed props with inline defaults.
  • Chores

    • Marked legacy prop type aliases and public typings as deprecated to guide migration to the new interfaces.
  • User-facing

    • Components now expose explicit runtime defaults (badge offset [0, 0], breadcrumb separator '/', button defaults including direction, type, nativeType and loading icon) with preserved behavior.
  • Documentation

    • Badge docs: offset default updated to [0, 0].

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jan 17, 2026

📝 Walkthrough

Walkthrough

Adds explicit exported TypeScript prop interfaces for Badge, Breadcrumb, and Button (and related items), deprecates ExtractPropTypes-based public aliases, updates SFCs to use type-only imports with defineProps() plus withDefaults(...), and adjusts some prop types/defaults and docs (badge offset).

Changes

Cohort / File(s) Summary
Badge: typings, component, docs
packages/components/badge/src/badge.ts, packages/components/badge/src/badge.vue, docs/en-US/component/badge.md
Introduces export interface BadgeProps; removes ExtractPropTypes-based exported alias; adds deprecated BadgePropsPublic = ExtractPublicPropTypes<...>; adjusts badgeStyle runtime type; .vue switched to defineProps<BadgeProps>() + withDefaults(...) with explicit defaults (including offset); docs default for offset set to [0, 0].
Breadcrumb & BreadcrumbItem: typings & components
packages/components/breadcrumb/src/breadcrumb.ts, packages/components/breadcrumb/src/breadcrumb.vue, packages/components/breadcrumb/src/breadcrumb-item.ts, packages/components/breadcrumb/src/breadcrumb-item.vue
Adds BreadcrumbProps and BreadcrumbItemProps interfaces and deprecation notices; replaces ExtractPropTypes-based public exports with *Public = ExtractPublicPropTypes<...> aliases (deprecated); SFCs now use type-only imports and defineProps<...>() + withDefaults(...) with defaults for separator, to, replace.
Button & ButtonGroup: typings, defaults, components
packages/components/button/src/button.ts, packages/components/button/src/button.vue, packages/components/button/src/button-group.ts, packages/components/button/src/button-group.vue
Adds ButtonProps interface and ButtonType / ButtonNativeType types; removes ExtractPropTypes-based exported aliases in favor of interfaces and deprecated *Public aliases; runtime buttonProps retained but annotated deprecated; SFCs switched to defineProps<ButtonProps>() + withDefaults(...) and introduce multiple explicit defaults (e.g., markRaw(Loading) for loadingIcon).

Sequence Diagram(s)

(omitted)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related issues

Possibly related PRs

Suggested reviewers

  • rzzf
  • btea
  • keeplearning66

Poem

🐰 I hopped through props and tidied each nest,
Replaced old aliases and gave defaults their rest.
With types snug and small changes in stride,
I left a few carrots — a joyful code ride. 🥕

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description only includes the template checklist items and a minimal reference to related issue #23399, but lacks substantive details about the changes, motivation, or impact. Add a detailed description explaining the refactoring objectives, why type-based definitions are preferred, what components are affected, and any breaking changes or migration steps for users.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main refactoring effort across multiple components to adopt type-based definitions instead of runtime prop objects.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing touches
  • 📝 Generate docstrings

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.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jan 17, 2026

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Jan 17, 2026

Open in StackBlitz

pnpm add https://pkg.pr.new/element-plus/element-plus@23414
npm i https://pkg.pr.new/element-plus/element-plus@23414
yarn add https://pkg.pr.new/element-plus/[email protected]

commit: fe7696b

@snowbitx snowbitx marked this pull request as ready for review January 17, 2026 13:25
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jan 17, 2026

🧪 Playground Preview: https://element-plus.run/?pr=23414
Please comment the example via this playground if needed.

Comment thread packages/components/badge/src/badge.ts
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

🤖 Fix all issues with AI agents
In `@packages/components/button/src/button.vue`:
- Around line 30-49: The Button booleans (disabled, plain, text, round,
autoInsertSpace) are now defaulting to false via withDefaults, breaking
use-button's nullish-coalescing fallback to globalConfig; update the props
declaration (the withDefaults call in button.vue where ButtonProps/props is
defined) to explicitly set those boolean props to undefined (restore tri-state
defaults) so useButton (use-button.ts) can detect undefined and fall back to
globalConfig.value, or alternately adjust useButton's merge logic to treat false
as a valid value only when explicitly specified (e.g., check prop === undefined
before using globalConfig).

Comment thread packages/components/button/src/button.vue
Comment thread packages/components/badge/src/badge.vue Outdated
Comment thread packages/components/breadcrumb/src/breadcrumb-item.vue Outdated
Comment thread packages/components/button/src/button-group.vue
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

🤖 Fix all issues with AI agents
In `@docs/en-US/component/badge.md`:
- Around line 62-73: Update the docs table row for the prop offset (referenced
as "offset ^(2.7.0)") so its Default cell matches the runtime default of [0, 0]
instead of "—"; locate the offset row in the badge props table and replace the
placeholder default with the literal "[0, 0]" (keeping existing formatting style
consistent with other default values).
🧹 Nitpick comments (1)
packages/components/badge/src/badge.vue (1)

30-46: Consider centralizing defaults to avoid drift

Defaults now live both here and in badgeProps. A shared badgeDefaults export could prevent divergence over time.

Comment thread docs/en-US/component/badge.md Outdated
@rzzf rzzf changed the title refactor(components): [badge] use type-based definitions refactor(components): [badge/breadcrumb/button] use type-based definitions Jan 17, 2026
@github-actions github-actions Bot added the CommitMessage::Unqualified Unqualified commit message label Jan 17, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jan 17, 2026

Hello, @snowbitx, your PR title does not meet the standards, please refer to here.
你好,@snowbitx,你的 PR 标题不符合规范,请参考这里

Comment thread packages/components/badge/src/badge.vue Outdated
Comment thread packages/components/breadcrumb/src/breadcrumb-item.vue Outdated
Copy link
Copy Markdown
Member

@rzzf rzzf left a comment

Choose a reason for hiding this comment

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

Thanks for all the back-and-forth

Copy link
Copy Markdown
Member

@keeplearning66 keeplearning66 left a comment

Choose a reason for hiding this comment

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

Thank you!

@snowbitx snowbitx requested a review from btea January 18, 2026 07:53
@btea btea merged commit 6a5f2ff into element-plus:dev Jan 18, 2026
16 checks passed
@github-actions
Copy link
Copy Markdown
Contributor

@snowbitx Thanks for your contribution! ❤️

@keeplearning66
Copy link
Copy Markdown
Member

keeplearning66 commented Jan 18, 2026

242650CF-176D-4f4f-83EF-B1F925C0923F

relate comment
We might need to explicitly set the default value of badgeStyle to undefined, because after merging this PR, the default value of badgeStyle in DevTools is shown as false, which is different from the previous version. 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants