Skip to content

refactor(components): [scrollbar] use type-based definitions#23427

Merged
btea merged 4 commits into
element-plus:devfrom
SevenDreamYang:use-type-based-definitions
Jan 18, 2026
Merged

refactor(components): [scrollbar] use type-based definitions#23427
btea merged 4 commits into
element-plus:devfrom
SevenDreamYang:use-type-based-definitions

Conversation

@SevenDreamYang
Copy link
Copy Markdown
Contributor

@SevenDreamYang SevenDreamYang commented Jan 18, 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

Summary by CodeRabbit

  • Refactor
    • Improved and unified TypeScript prop interfaces for scrollbar components, replacing prior runtime prop descriptors with typed contracts.
    • Applied explicit default values across bar, scrollbar, and thumb props for more predictable behavior and better IDE support.
    • Removed legacy prop aliases in favor of the new interfaces; deprecation notes added for the older aliases.

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

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jan 18, 2026

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jan 18, 2026

📝 Walkthrough

Walkthrough

Replaces runtime prop objects and ExtractPropTypes aliases with explicit TypeScript interfaces for scrollbar components; components now use defineProps() (withDefaults for defaults) and imports use ExtractPublicPropTypes. Deprecation comments added for removed aliases.

Changes

Cohort / File(s) Summary
Type definition files
packages/components/scrollbar/src/bar.ts, packages/components/scrollbar/src/scrollbar.ts, packages/components/scrollbar/src/thumb.ts
Removed export type XProps = ExtractPropTypes<typeof xProps> aliases; added explicit export interface XProps { ... } declarations (BarProps, ScrollbarProps, ThumbProps); removed ExtractPropTypes imports, retained ExtractPublicPropTypes for public aliases; added deprecation comment blocks.
Vue component files
packages/components/scrollbar/src/bar.vue, packages/components/scrollbar/src/scrollbar.vue, packages/components/scrollbar/src/thumb.vue
Switched from defineProps(runtimePropObject) to defineProps<Interface>(); applied withDefaults(...) where defaults were set; replaced runtime prop-object imports with type imports referencing the new interfaces.

Sequence Diagram(s)

(omitted — changes are type/prop-interface refactors without new multi-component control flow)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • btea
  • keeplearning66

Poem

🐰 I hopped through props beneath moonlight,

Swapped runtime shapes for types polite,
WithDefaults tucked each default tight,
Deprecations marked, interfaces bright,
A rabbit's nibble made the code just right.

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Description check ⚠️ Warning The description is largely incomplete; it only shows the unchecked checklist template without substantive details about the changes, objectives, or rationale for the refactor. Add a clear description of the refactoring's purpose, what changed (e.g., migration from ExtractPropTypes to TypeScript interfaces), and any breaking changes or migration notes for users.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title directly and accurately reflects the main refactoring: converting scrollbar component from runtime prop definitions to type-based definitions using TypeScript interfaces.
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.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Jan 18, 2026

Open in StackBlitz

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

commit: 9ed3a41

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jan 18, 2026

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

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: 2

🤖 Fix all issues with AI agents
In `@packages/components/scrollbar/src/scrollbar.ts`:
- Around line 83-86: The ariaOrientation prop's type currently includes the
string literal 'undefined' which is incorrect; update the ariaOrientation
property in the Scrollbar type definition to remove the string 'undefined'
(i.e., use 'horizontal' | 'vertical' or, if you need to allow the explicit
undefined value, use undefined without quotes) since the optional ? already
permits it being unset; modify the ariaOrientation declaration in
packages/components/scrollbar/src/scrollbar.ts accordingly.

In `@packages/components/scrollbar/src/scrollbar.vue`:
- Around line 58-69: The boolean props on the Scrollbar component (declared via
defineProps<ScrollbarProps>() and merged into props) are currently left
undefined by type-only props; update the withDefaults call that constructs props
to explicitly set native, noresize, and always to false so they default to false
at runtime (preserving backward compatibility with existing consumers that test
props.native === false or similar) — locate the
withDefaults(defineProps<ScrollbarProps>(), { ... }) block and add native:
false, noresize: false, always: false to its defaults.

Comment thread packages/components/scrollbar/src/scrollbar.ts
Comment thread packages/components/scrollbar/src/scrollbar.vue
Comment thread packages/components/scrollbar/src/scrollbar.ts Outdated
@btea btea merged commit 71ac3d4 into element-plus:dev Jan 18, 2026
20 of 23 checks passed
@github-actions
Copy link
Copy Markdown
Contributor

@SevenDreamYang Thanks for your contribution! ❤️

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.

3 participants