picker icon indicating copy to clipboard operation
picker copied to clipboard

fix: add 'preset-click' operation type to RangePicker

Open QdabuliuQ opened this issue 5 months ago • 3 comments

🤔 This is a ...

  • [ ] 🆕 New feature
  • [x] 🐞 Bug fix
  • [ ] 📝 Site / documentation improvement
  • [ ] 📽️ Demo improvement
  • [ ] 💄 Component style improvement
  • [ ] 🤖 TypeScript definition improvement
  • [ ] 📦 Bundle size optimization
  • [ ] ⚡️ Performance optimization
  • [ ] ⭐️ Feature enhancement
  • [ ] 🌐 Internationalization
  • [ ] 🛠 Refactoring
  • [ ] 🎨 Code style optimization
  • [ ] ✅ Test Case
  • [ ] 🔀 Branch merge
  • [ ] ⏩ Workflow
  • [ ] ⌨️ Accessibility improvement
  • [ ] ❓ Other (about what?)

🔗 Related Issues

fix: https://github.com/ant-design/ant-design/issues/54436

💡 Background and Solution

DatePicker with needConfirm={false}, showTime, and presets settings fails to auto-close the dropdown when a preset option is clicked. DatePicker 设置 needConfirm={false} / showTime / presets 的时候,点击 presets 选项后无法自动关闭弹出层;翻译成为英文

onPresetSubmit 回调中调用 lastOperation 方法传入 preset-click;

📝 Change Log

  • Read Keep a Changelog! Track your changes, like a cat tracks a laser pointer.
  • Describe the impact of the changes on developers, not the solution approach.
  • Reference: https://ant.design/changelog
Language Changelog
🇺🇸 English Fix popup not auto-closing when clicking presets after setting presets / needConfirm={false}
🇨🇳 Chinese 修复设置 presets / needConfirm={false} 后点击 presets 无法自动关闭弹出层

Summary by CodeRabbit

  • 新功能
    • 现在在选择预设时间范围时,将记录一次新的操作类型以提升交互体验。

QdabuliuQ avatar Jul 22 '25 10:07 QdabuliuQ

Walkthrough

本次变更在 RangePicker 的预设点击逻辑中,新增了在特定条件下调用 lastOperation('preset-click') 的操作,并将 OperationType 类型扩展以支持 'preset-click'。其余逻辑未发生变化。

Changes

文件/分组 变更摘要
src/PickerInput/RangePicker.tsx onPresetSubmit 内部,triggerSubmitChange 返回 true 时,新增调用 lastOperation('preset-click')
src/PickerInput/hooks/useRangeActive.ts OperationType 类型新增 'preset-click' 字面量类型。

Estimated code review effort

2 (~12 分钟)

Suggested reviewers

  • zombieJ

Poem

🐇
预设一键点,面板随风关,
类型多一项,逻辑更完善。
代码小更新,体验大提升,
兔子挥挥手,愉快迎新天!

[!WARNING] There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

src/PickerInput/hooks/useRangeActive.ts

Oops! Something went wrong! :(

ESLint: 8.57.1

Error: Cannot read config file: /.eslintrc.js Error: Cannot find module '@umijs/fabric/dist/eslint' Require stack:

  • /.eslintrc.js
  • /node_modules/.pnpm/@[email protected]/node_modules/@eslint/eslintrc/dist/eslintrc.cjs
  • /node_modules/.pnpm/[email protected]/node_modules/eslint/lib/cli-engine/cli-engine.js
  • /node_modules/.pnpm/[email protected]/node_modules/eslint/lib/eslint/eslint.js
  • /node_modules/.pnpm/[email protected]/node_modules/eslint/lib/eslint/index.js
  • /node_modules/.pnpm/[email protected]/node_modules/eslint/lib/cli.js
  • /node_modules/.pnpm/[email protected]/node_modules/eslint/bin/eslint.js at Module._resolveFilename (node:internal/modules/cjs/loader:1369:15) at require.resolve (node:internal/modules/helpers:145:19) at Object. (/.eslintrc.js:2:21) at Module._compile (node:internal/modules/cjs/loader:1692:14) at Object..js (node:internal/modules/cjs/loader:1824:10) at Module.load (node:internal/modules/cjs/loader:1427:32) at Module._load (node:internal/modules/cjs/loader:1250:12) at TracingChannel.traceSync (node:diagnostics_channel:322:14) at wrapModuleLoad (node:internal/modules/cjs/loader:235:24) at Module.require (node:internal/modules/cjs/loader:1449:12)
src/PickerInput/RangePicker.tsx

Oops! Something went wrong! :(

ESLint: 8.57.1

Error: Cannot read config file: /.eslintrc.js Error: Cannot find module '@umijs/fabric/dist/eslint' Require stack:

  • /.eslintrc.js
  • /node_modules/.pnpm/@[email protected]/node_modules/@eslint/eslintrc/dist/eslintrc.cjs
  • /node_modules/.pnpm/[email protected]/node_modules/eslint/lib/cli-engine/cli-engine.js
  • /node_modules/.pnpm/[email protected]/node_modules/eslint/lib/eslint/eslint.js
  • /node_modules/.pnpm/[email protected]/node_modules/eslint/lib/eslint/index.js
  • /node_modules/.pnpm/[email protected]/node_modules/eslint/lib/cli.js
  • /node_modules/.pnpm/[email protected]/node_modules/eslint/bin/eslint.js at Module._resolveFilename (node:internal/modules/cjs/loader:1369:15) at require.resolve (node:internal/modules/helpers:145:19) at Object. (/.eslintrc.js:2:21) at Module._compile (node:internal/modules/cjs/loader:1692:14) at Object..js (node:internal/modules/cjs/loader:1824:10) at Module.load (node:internal/modules/cjs/loader:1427:32) at Module._load (node:internal/modules/cjs/loader:1250:12) at TracingChannel.traceSync (node:diagnostics_channel:322:14) at wrapModuleLoad (node:internal/modules/cjs/loader:235:24) at Module.require (node:internal/modules/cjs/loader:1449:12)

📜 Recent review details

Configuration used: CodeRabbit UI Review profile: CHILL Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d3dc2631d28a31da55dce5c8093961b560336037 and cc1075ab1ddd6fbe571081b1c057bc870c6df5cb.

📒 Files selected for processing (2)
  • src/PickerInput/RangePicker.tsx (1 hunks)
  • src/PickerInput/hooks/useRangeActive.ts (1 hunks)
🔇 Additional comments (2)
src/PickerInput/hooks/useRangeActive.ts (1)

5-5: 类型扩展合理,符合现有架构模式

新增的 'preset-click' 操作类型与现有的 'input''panel' 保持一致,用于标识预设点击操作。这个扩展为修复特定配置下的弹窗关闭问题提供了必要的类型支持。

src/PickerInput/RangePicker.tsx (1)

498-498: 修复逻辑正确,时序合理

triggerSubmitChange 成功后调用 lastOperation('preset-click') 来记录操作类型,这与现有架构保持一致(类似第521行和第640行的操作)。调用时序正确,确保在 triggerOpen(false, { force: true }) 之前记录操作类型,有助于修复特定配置下的弹窗关闭问题。

✨ Finishing Touches
  • [ ] 📝 Generate Docstrings
🧪 Generate unit tests
  • [ ] Create PR with unit tests
  • [ ] Post copyable unit tests in a comment

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

coderabbitai[bot] avatar Jul 22 '25 10:07 coderabbitai[bot]

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
picker ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 22, 2025 10:31am

vercel[bot] avatar Jul 22 '25 10:07 vercel[bot]

Codecov Report

:white_check_mark: All modified and coverable lines are covered by tests. :white_check_mark: Project coverage is 98.80%. Comparing base (d3dc263) to head (cc1075a). :warning: Report is 23 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #933   +/-   ##
=======================================
  Coverage   98.80%   98.80%           
=======================================
  Files          65       65           
  Lines        2669     2670    +1     
  Branches      742      742           
=======================================
+ Hits         2637     2638    +1     
  Misses         29       29           
  Partials        3        3           

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

codecov[bot] avatar Jul 22 '25 10:07 codecov[bot]