Skip to content

Conversation

@shenjunjian
Copy link
Collaborator

@shenjunjian shenjunjian commented Oct 15, 2025

PR

为picker组件添加 popperOptions属性
为select, datepicker, timepicker,timeselect等补充 popperOptions属性的api文档

PR Checklist

Please check if your PR fulfills the following requirements:

  • The commit message follows our Commit Message Guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

What is the current behavior?

Issue Number: N/A

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Summary by CodeRabbit

  • New Features

    • Added a new popper-options prop to Date Picker, Time Picker, Time Select, and Select for advanced popup customization (e.g., boundaries, scrolling, hide behavior). Defaults preserve current behavior and work on desktop and mobile.
  • Documentation

    • Updated API docs and demos to showcase popper-options usage, with localized descriptions and examples.

@github-actions github-actions bot added the bug Something isn't working label Oct 15, 2025
@coderabbitai
Copy link

coderabbitai bot commented Oct 15, 2025

Walkthrough

Adds a new popper options interface (IPopperOption) and corresponding public prop to multiple demo API files, and introduces a popperOptions prop to the core picker props. No control-flow logic changes are described; updates are type and prop additions for configuring popper behavior.

Changes

Cohort / File(s) Summary
Demo APIs: add IPopperOption and popper-options prop
examples/sites/demos/apis/date-picker.js, examples/sites/demos/apis/select.js, examples/sites/demos/apis/time-picker.js, examples/sites/demos/apis/time-select.js
Added IPopperOption interface (bubbling, followReferenceHide, removeOnDestroy, updateHiddenPopperOnScroll, boundariesElement, ignoreBoundaries, scrollParent) and new public prop popper-options (typed as IPopperOption) with defaults and localized descriptions.
Core picker props: add popperOptions
packages/vue/src/picker/src/type.ts
Added popperOptions to pickerProps (type: Object, default: factory returning {}) enabling popper configuration on the base picker.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor User
  participant App as App Component
  participant UI as Picker/Select/Date/Time Component
  participant Core as Base Picker (pickerProps)
  participant Popper as Popper Engine

  User->>App: Interacts with picker
  App->>UI: Pass props (including popper-options / popperOptions)
  UI->>Core: Forward popperOptions (object)
  Core->>Popper: Initialize/Update with popperOptions
  Note right of Popper: Uses boundariesElement, bubbling, etc.
  Popper-->>Core: Positioned overlay
  Core-->>UI: Render popup per options
  UI-->>User: Display dropdown/calendar
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

A nibble of props, a hop of types,
New popper options, snug and ripe.
I twitch my whiskers, configs in tow—
Boundaries set, the overlays flow.
In burrows of code I softly cheer:
“Pop! Pop!” says UI—crystal clear. 🐇✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title succinctly describes the primary change—adding the popperOptions prop to the Picker component—and aligns with the main implementation in the pull request, making it clear and specific for anyone reviewing the commit history.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch shen/fix-picker-popperoptions

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

@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

♻️ Duplicate comments (3)
examples/sites/demos/apis/select.js (1)

1051-1065: Interface duplication detected.

This IPopperOption interface is identical to the one defined in time-picker.js (lines 400-414), time-select.js (lines 218-234), and date-picker.js (lines 683-697). As mentioned in the review of time-picker.js, please consolidate this interface into a shared types file to eliminate duplication and make the properties optional to match the documented defaults.

examples/sites/demos/apis/time-select.js (1)

218-234: Interface duplication detected.

This IPopperOption interface duplicates definitions in time-picker.js, select.js, and date-picker.js. Please refer to the recommendations in the time-picker.js review to consolidate this interface and make properties optional.

examples/sites/demos/apis/date-picker.js (1)

683-697: Interface duplication detected.

This is the fourth instance of the identical IPopperOption interface across the demo API files. As recommended in previous comments, consolidate this into a shared type definition and make all properties optional.

🧹 Nitpick comments (4)
examples/sites/demos/apis/time-picker.js (1)

165-177: Provide demo examples for popper-options and normalize its defaultValue formatting

  • In examples/sites/demos/apis/time-picker.js, pcDemo and mfDemo are both empty; add demo entries (demoId + code files) to show how to configure IPopperOption for TimePicker.
  • Change defaultValue: ' { }' to defaultValue: '{}' for consistency with other prop definitions.
examples/sites/demos/apis/select.js (1)

438-450: Add Popper options demos for Select. Both pcDemo and mfDemo in examples/sites/demos/apis/select.js are empty; please add demo IDs illustrating popper-options usage for PC and mobile-first.

examples/sites/demos/apis/time-select.js (1)

131-143: Add demo examples for popper-options
Both pcDemo and mfDemo are empty in examples/sites/demos/apis/time-select.js and no usage of popper-options appears elsewhere; add example code or remove these empty fields.

examples/sites/demos/apis/date-picker.js (1)

218-230: Populate date-picker’s popper-options demos
In examples/sites/demos/apis/date-picker.js the pcDemo and mfDemo fields for popper-options are empty; add and reference demo files (e.g. popper-options.vue) for both PC and mobile-first modes, mirroring other components’ demos.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c8cfea3 and 4d2c38a.

📒 Files selected for processing (5)
  • examples/sites/demos/apis/date-picker.js (2 hunks)
  • examples/sites/demos/apis/select.js (2 hunks)
  • examples/sites/demos/apis/time-picker.js (2 hunks)
  • examples/sites/demos/apis/time-select.js (2 hunks)
  • packages/vue/src/picker/src/type.ts (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: PR E2E Test (pnpm test:e2e3)

Comment on lines +400 to 414
{
name: 'IPopperOption',
type: 'interface',
code: `
interface IPopperOption {
bubbling: boolean // 是否监听元素所有上级有滚动元素的scroll事件,监听到则更新popper的位置。用于解决某些弹出层位置在页面滚动时,位置不正确的场景,默认false
followReferenceHide: boolean // 当触发源隐藏时,自动隐藏弹出层,默认true
removeOnDestroy: boolean // 弹出层消失后,是否移除弹出层的DOM元素,布尔false
updateHiddenPopperOnScroll: boolean // 滚动过程中是否更新隐藏的弹出层位置
boundariesElement: 'viewport' | 'body' | HTMLElement // 滚动过程中,弹出层的碰撞边界。 默认值为: 'viewport'
ignoreBoundaries: boolean // 忽略边界判断,弹出的位置始终是设置的 placement 值
scrollParent: HTMLElement // 指定滚动的父节点,优化级最高。 默认为null
}
`
}
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion | 🟠 Major

Consolidate duplicated IPopperOption interface and make properties optional.

The IPopperOption interface is duplicated across multiple files (date-picker.js, select.js, time-select.js, and here). This violates the DRY principle and increases maintenance burden.

Additionally, all properties are defined as required, but the comments indicate default values (e.g., "默认false", "默认true", "默认为null"), suggesting these should be optional properties.

Consider:

  1. Create a shared type definition: Move IPopperOption to a common types file (e.g., examples/sites/demos/apis/types/popper.ts) and import it across all demo API files.
  2. Make properties optional: Update the interface to use optional markers:
 interface IPopperOption {
-  bubbling: boolean // 是否监听元素所有上级有滚动元素的scroll事件,监听到则更新popper的位置。用于解决某些弹出层位置在页面滚动时,位置不正确的场景,默认false
-  followReferenceHide: boolean // 当触发源隐藏时,自动隐藏弹出层,默认true
-  removeOnDestroy: boolean // 弹出层消失后,是否移除弹出层的DOM元素,布尔false
-  updateHiddenPopperOnScroll: boolean  // 滚动过程中是否更新隐藏的弹出层位置
-  boundariesElement: 'viewport' | 'body' | HTMLElement // 滚动过程中,弹出层的碰撞边界。 默认值为: 'viewport'
-  ignoreBoundaries: boolean  // 忽略边界判断,弹出的位置始终是设置的 placement 值
-  scrollParent:  HTMLElement  // 指定滚动的父节点,优化级最高。 默认为null
+  bubbling?: boolean // 是否监听元素所有上级有滚动元素的scroll事件,监听到则更新popper的位置。用于解决某些弹出层位置在页面滚动时,位置不正确的场景,默认false
+  followReferenceHide?: boolean // 当触发源隐藏时,自动隐藏弹出层,默认true
+  removeOnDestroy?: boolean // 弹出层消失后,是否移除弹出层的DOM元素,布尔false
+  updateHiddenPopperOnScroll?: boolean  // 滚动过程中是否更新隐藏的弹出层位置
+  boundariesElement?: 'viewport' | 'body' | HTMLElement // 滚动过程中,弹出层的碰撞边界。 默认值为: 'viewport'
+  ignoreBoundaries?: boolean  // 忽略边界判断,弹出的位置始终是设置的 placement 值
+  scrollParent?: HTMLElement  // 指定滚动的父节点,优化级最高。 默认为null
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
{
name: 'IPopperOption',
type: 'interface',
code: `
interface IPopperOption {
bubbling: boolean // 是否监听元素所有上级有滚动元素的scroll事件,监听到则更新popper的位置。用于解决某些弹出层位置在页面滚动时,位置不正确的场景,默认false
followReferenceHide: boolean // 当触发源隐藏时,自动隐藏弹出层,默认true
removeOnDestroy: boolean // 弹出层消失后,是否移除弹出层的DOM元素,布尔false
updateHiddenPopperOnScroll: boolean // 滚动过程中是否更新隐藏的弹出层位置
boundariesElement: 'viewport' | 'body' | HTMLElement // 滚动过程中,弹出层的碰撞边界。 默认值为: 'viewport'
ignoreBoundaries: boolean // 忽略边界判断,弹出的位置始终是设置的 placement 值
scrollParent: HTMLElement // 指定滚动的父节点,优化级最高。 默认为null
}
`
}
{
name: 'IPopperOption',
type: 'interface',
code: `
interface IPopperOption {
bubbling?: boolean // 是否监听元素所有上级有滚动元素的scroll事件,监听到则更新popper的位置。用于解决某些弹出层位置在页面滚动时,位置不正确的场景,默认false
followReferenceHide?: boolean // 当触发源隐藏时,自动隐藏弹出层,默认true
removeOnDestroy?: boolean // 弹出层消失后,是否移除弹出层的DOM元素,布尔false
updateHiddenPopperOnScroll?: boolean // 滚动过程中是否更新隐藏的弹出层位置
boundariesElement?: 'viewport' | 'body' | HTMLElement // 滚动过程中,弹出层的碰撞边界。 默认值为: 'viewport'
ignoreBoundaries?: boolean // 忽略边界判断,弹出的位置始终是设置的 placement 值
scrollParent?: HTMLElement // 指定滚动的父节点,优化级最高。 默认为null
}
`
}
🤖 Prompt for AI Agents
In examples/sites/demos/apis/time-picker.js around lines 400 to 414, the
IPopperOption interface is duplicated and declares all properties as required
despite comments indicating defaults; extract this interface into a shared
module (e.g., examples/sites/demos/apis/types/popper.ts), change each property
to optional (use ?), export the interface from that file, replace the inline
definition here with an import from the new shared types file, and update the
other files (date-picker.js, select.js, time-select.js) to import the same
shared IPopperOption to avoid duplication and ensure default/optional semantics
are correct.

Comment on lines +78 to +81
popperOptions: {
type: Object,
default: () => ({})
},
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion | 🟠 Major

Improve type safety for popperOptions prop.

The popperOptions prop currently uses the generic Object type, which provides no type checking or IntelliSense support for consumers. Since a well-defined IPopperOption interface exists in the demo API files, consider creating a proper TypeScript interface and using it here.

Recommendation:

  1. Create a shared TypeScript type definition file (e.g., packages/vue/src/picker/src/popper-types.ts):
export interface IPopperOption {
  bubbling?: boolean
  followReferenceHide?: boolean
  removeOnDestroy?: boolean
  updateHiddenPopperOnScroll?: boolean
  boundariesElement?: 'viewport' | 'body' | HTMLElement
  ignoreBoundaries?: boolean
  scrollParent?: HTMLElement
}
  1. Import and use the interface in this file:
+import type { IPopperOption } from './popper-types'

 export const pickerProps = {
   // ...
   popperOptions: {
-    type: Object,
+    type: Object as PropType<IPopperOption>,
     default: () => ({})
   },

This change would provide better developer experience through:

  • Type checking at compile time
  • IDE autocomplete for configuration options
  • Better documentation through types
🤖 Prompt for AI Agents
In packages/vue/src/picker/src/type.ts around lines 78 to 81 the popperOptions
prop is typed as generic Object; create a proper interface and use it instead:
add a new file packages/vue/src/picker/src/popper-types.ts exporting
IPopperOption with the suggested fields (bubbling, followReferenceHide,
removeOnDestroy, updateHiddenPopperOnScroll, boundariesElement,
ignoreBoundaries, scrollParent), then import IPopperOption into type.ts and
change the prop declaration to use that interface (and update the default to
return an empty object typed as IPopperOption) so consumers get compile-time
type checking and IDE autocomplete.

@zzcr zzcr merged commit 2327c03 into dev Oct 27, 2025
10 of 11 checks passed
@zzcr zzcr deleted the shen/fix-picker-popperoptions branch October 27, 2025 03:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants