Skip to content

feat: support confirmOnDoubleClick config for needConfirm#961

Closed
QDyanbing wants to merge 1 commit intoreact-component:masterfrom
QDyanbing:codex/fix-57560-need-confirm-range-double-click
Closed

feat: support confirmOnDoubleClick config for needConfirm#961
QDyanbing wants to merge 1 commit intoreact-component:masterfrom
QDyanbing:codex/fix-57560-need-confirm-range-double-click

Conversation

@QDyanbing
Copy link
Copy Markdown
Contributor

@QDyanbing QDyanbing commented Apr 7, 2026

变更说明

  • needConfirm 增加对象配置形式,支持通过 confirmOnDoubleClick 控制是否允许双击直接确认
  • 保持原有 needConfirm 布尔用法兼容,默认行为不变
  • 补充单选和范围选择场景的测试,覆盖禁用双击确认的行为

测试计划

  • 已补充单测覆盖 confirmOnDoubleClick: false

关联问题

close ant-design/ant-design#57560

Summary by CodeRabbit

发行说明

  • 新功能

    • 添加了对双击确认行为的细粒度控制。用户现在可以通过 needConfirm 配置对象来独立控制是否在双击时确认日期/时间选择,使用 { confirmOnDoubleClick: false } 可禁用此行为。
  • 测试

    • 新增测试用例以验证双击确认配置的各种场景。

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 7, 2026

@QDyanbing is attempting to deploy a commit to the React Component Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 7, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 5cf88fd3-44a4-43ed-880c-eb587ffe72ff

📥 Commits

Reviewing files that changed from the base of the PR and between d27127f and a9e1181.

📒 Files selected for processing (7)
  • src/PickerInput/Popup/PopupPanel.tsx
  • src/PickerInput/RangePicker.tsx
  • src/PickerInput/SinglePicker.tsx
  • src/PickerInput/hooks/useFilledProps.ts
  • src/interface.tsx
  • tests/new-range.spec.tsx
  • tests/picker.spec.tsx

概览

此更改为日期选择器组件添加了对双击确认行为的细粒度控制。通过引入新的 NeedConfirmConfig 类型,允许 needConfirm 配置为布尔值或包含 confirmOnDoubleClick 选项的对象,进而控制双击时是否提交选择。

变更

类型/文件 摘要
类型定义与接口
src/interface.tsx
添加了新的导出类型 `NeedConfirmConfig = boolean
Hook 更新
src/PickerInput/hooks/useFilledProps.ts
引入新的 FilledProps<InProps, DateType, UpdaterProps> 类型。更新 needConfirm 的推导逻辑:当为对象时,提取其 confirmOnDoubleClick 属性(默认为 true),并将 mergedNeedConfirm 设为 true。返回的合并 props 现包含 confirmOnDoubleClick 字段。
Popup 确认行为
src/PickerInput/Popup/PopupPanel.tsx
扩展 PopupPanelProps 以要求新的布尔属性 confirmOnDoubleClick。修改 PickerHackContextonCellDblClick 处理器:仅当 needConfirmconfirmOnDoubleClick 同时为 true 时才调用 onSubmit()
Picker 组件
src/PickerInput/SinglePicker.tsx, src/PickerInput/RangePicker.tsx
两个 picker 组件现从 filledProps 解构 confirmOnDoubleClick 属性,并将其转发至 Popup 组件。通过此传递机制,控制双击确认的启用状态。
测试用例
tests/picker.spec.tsx, tests/new-range.spec.tsx
新增测试验证 needConfirm={{ confirmOnDoubleClick: false }} 配置下的行为:双击时不触发 onChange,选择器保持打开状态。现有测试也调整为使用显式的 needConfirm={{}} 配置。

预估代码审查工作量

🎯 3 (中等) | ⏱️ ~25 分钟

建议审查者

  • afc163
  • zombieJ

诗歌

🐰 双击之时,我来掌控,
对象之中,真假已现,
确认之舞,从此可调,
Props 层层传,逻辑更清晰,
选择器之花,绽放新风采!

🚥 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
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed PR标题准确总结了主要变更:添加对needConfirm配置中confirmOnDoubleClick属性的支持,这是本次变更的核心功能。

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a new configuration option, confirmOnDoubleClick, within the needConfirm prop for date and range pickers. This allows developers to explicitly control whether a double-click action on a picker cell triggers a submission. The changes involve updating the needConfirm type definition to support a configuration object, implementing the logic in the useFilledProps hook to extract this setting, and propagating the prop through SinglePicker, RangePicker, and PopupPanel. Additionally, unit tests have been added to verify that the submission behavior correctly respects the confirmOnDoubleClick setting. I have no feedback to provide.

@QDyanbing
Copy link
Copy Markdown
Contributor Author

暂时不支持该功能,先关闭了;

@QDyanbing QDyanbing closed this Apr 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TimePicker.RangePicker插件在使用needConfirm为true时,是否可以阻止双击“时分秒”选项时跳转到下一个rangePicker

1 participant