Skip to content

feat(SwipeCell): add customizable threshold prop for swipe actions#13792

Open
quietdw wants to merge 3 commits intoyouzan:mainfrom
quietdw:feature/swipe-cell-threshold
Open

feat(SwipeCell): add customizable threshold prop for swipe actions#13792
quietdw wants to merge 3 commits intoyouzan:mainfrom
quietdw:feature/swipe-cell-threshold

Conversation

@quietdw
Copy link

@quietdw quietdw commented Mar 6, 2026

SwipeCell的threshold 支持自定义。

用户反馈threshold太小了,容易误触。

@gemini-code-assist
Copy link

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

此 PR 为 SwipeCell 组件引入了一个新的可自定义的 threshold 属性。此增强功能旨在解决用户关于默认阈值过小导致容易误触的反馈,允许开发者调整滑动操作的灵敏度,从而改善用户体验。

Highlights

  • 新增可自定义的阈值属性: 为 SwipeCell 组件添加了 threshold 属性,允许用户自定义滑动操作的触发点。
  • 默认阈值: threshold 属性的默认值为 0.15
  • 更新滑动逻辑: 修改了 toggle 函数中的逻辑,使其使用新的 threshold 属性来计算滑动触发的临界值。
  • 新增测试用例: 增加了新的测试用例,以验证自定义 threshold 属性的功能是否符合预期。

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • packages/vant/src/swipe-cell/SwipeCell.tsx
    • 添加了 threshold 属性,并设置了默认值。
    • 修改了 toggle 函数,使其使用新的 threshold 属性。
  • packages/vant/src/swipe-cell/test/index.spec.js
    • 添加了测试用例,以验证自定义 threshold 属性的功能。
Activity
  • 目前没有人工活动。
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@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

本次 PR 为 SwipeCell 组件新增了 threshold 属性,用于自定义滑动阈值,解决了用户反馈的易误触问题。代码实现清晰,并添加了相应的单元测试。

我有一个建议,希望能帮助提升代码的健壮性:

  • threshold 属性增加一个验证器,确保其值在 0 到 1 之间,以避免潜在的非预期行为。

此外,为了让开发者能了解到这个新功能,建议在组件的 README.md 文档中补充关于新属性 threshold 的说明。

@codecov-commenter
Copy link

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.99%. Comparing base (ec5b45b) to head (b72e567).
⚠️ Report is 211 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #13792      +/-   ##
==========================================
+ Coverage   89.60%   89.99%   +0.38%     
==========================================
  Files         257      257              
  Lines        7013     7063      +50     
  Branches     1736     1755      +19     
==========================================
+ Hits         6284     6356      +72     
+ Misses        384      371      -13     
+ Partials      345      336       -9     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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

@quietdw
Copy link
Author

quietdw commented Mar 6, 2026

我这次 PR 只改动了 SwipeCell(新增 threshold props、补测试与文档),本地跑 SwipeCell 相关用例均通过。

当前 CI 失败的报错指向 src/composables/use-height.ts(setTimeout 在测试环境 teardown 后仍触发,最终在 Node 环境里访问 window 导致 ReferenceError: window is not defined),触发点出现在 src/submit-bar/test/index.spec.ts 执行期间。看起来与本 PR 修改无关,更像是测试环境/异步定时器清理相关的已有问题。

我可以按维护建议另开 PR 专门修复 use-height.ts 的定时器清理/SSR 兼容,避免本 PR 引入非单一性改动;

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.

2 participants