Skip to content

refactor(components): [popper] use type-based definitions#23450

Merged
Dsaquel merged 3 commits into
element-plus:devfrom
snowbitx:refactor/use-type-popper
Jan 19, 2026
Merged

refactor(components): [popper] use type-based definitions#23450
Dsaquel merged 3 commits into
element-plus:devfrom
snowbitx:refactor/use-type-popper

Conversation

@snowbitx
Copy link
Copy Markdown
Contributor

@snowbitx snowbitx 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

    • Reworked Popper component props and defaults into explicit typed interfaces, simplifying prop typing and runtime defaults across Popper, Content, Trigger and Arrow.
    • Components now apply explicit default values (e.g., role/defaults for popper content/arrow offset) via typed defaults rather than inline prop descriptors, improving consistency.
  • Chores

    • Removed legacy prop extraction usage and cleaned up type exports and imports.

✏️ 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

Refactors Popper props from ExtractPropTypes-derived runtime descriptors to explicit TypeScript interfaces and separate defaults; updates components to use typed defineProps with withDefaults and adjusts related types/imports across popper arrow, content, popper, trigger, and utilities.

Changes

Cohort / File(s) Change Summary
Arrow component
packages/components/popper/src/arrow.ts
Added PopperArrowProps interface and PopperArrowPropsPublic alias, removed ExtractPropTypes import, introduced popperArrowPropsDefaults, added usePopperArrowProps/UsePopperArrowProps aliases and ElPopperArrowInstance alias.
Content core types & defaults
packages/components/popper/src/content.ts
Added PopperCoreConfigProps and PopperContentProps interfaces, PopperCoreConfigPropsPublic/PopperContentPropsPublic aliases, introduced popperCoreConfigPropsDefaults and popperContentPropsDefaults, and import adjustments to use arrow defaults/types.
Content component
packages/components/popper/src/content.vue
Switched from runtime popperContentProps descriptor to defineProps<PopperContentProps>() with withDefaults(..., popperContentPropsDefaults); updated imports to use the typed props and defaults.
Content DOM composable
packages/components/popper/src/composables/use-content-dom.ts
Applied non-null assertion to props.effect in contentClass computation (ns.is(props.effect!)).
Main Popper types
packages/components/popper/src/popper.ts
Added PopperProps interface (including optional role), removed ExtractPropTypes-derived exported type, added PopperPropsPublic = ExtractPublicPropTypes<typeof popperProps>, preserved usePopperProps alias/deprecation notes.
Main Popper component
packages/components/popper/src/popper.vue
Changed props declaration to withDefaults(defineProps<PopperProps>(), { role: 'tooltip' }), importing the PopperProps type.
Trigger types
packages/components/popper/src/trigger.ts
Added PopperTriggerProps interface defining optional event handlers and related props; removed previous typeof popperTriggerProps alias.
Trigger component
packages/components/popper/src/trigger.vue
Switched from defineProps(popperTriggerProps) to withDefaults(defineProps<PopperTriggerProps>(), {}) and updated imports to use the PopperTriggerProps type.
Utilities
packages/components/popper/src/utils.ts
Narrowed deriveExtraModifiers parameter type to NonNullable<PopperCoreConfigProps['popperOptions']>['modifiers'] (non-nullable index access).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested reviewers

  • rzzf
  • btea

Poem

🐰 With whiskers twitching, I compile the night,
Types hop in place, all tidy and bright,
Defaults snugly tucked, no extractor in sight,
Interfaces singing, refactor delight,
A rabbit's small cheer for code done right.

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main refactor: converting popper component definitions from runtime prop objects to type-based definitions across multiple files.
Description check ✅ Passed The description includes all required checklist items marked as completed, mentions the contributing guide, confirms dev branch targeting, and provides issue reference #23399.

✏️ 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@23450
npm i https://pkg.pr.new/element-plus/element-plus@23450
yarn add https://pkg.pr.new/element-plus/[email protected]

commit: 4568819

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jan 18, 2026

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

Comment thread packages/components/popper/src/trigger.vue
Comment thread packages/components/popper/src/content.ts
@wjp980108
Copy link
Copy Markdown
Contributor

When can this PR be merged? My modified tooltip component needs the content modified in this PR. @rzzf

@Dsaquel Dsaquel merged commit 3dcb61f into element-plus:dev Jan 19, 2026
20 checks passed
@github-actions
Copy link
Copy Markdown
Contributor

@snowbitx 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.

4 participants