-
-
Notifications
You must be signed in to change notification settings - Fork 225
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add pointDown action #444
base: master
Are you sure you want to change the base?
Conversation
Walkthrough此次更改引入了对 Changes
Poem
Tip We have updated our review workflow to use the Anthropic's Claude family of models. Please share any feedback in the discussion post on our Discord. Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
pointerDown 还是 pointDown? |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #444 +/- ##
==========================================
- Coverage 97.87% 96.87% -1.00%
==========================================
Files 13 13
Lines 799 801 +2
Branches 235 241 +6
==========================================
- Hits 782 776 -6
- Misses 17 25 +8 ☔ View full report in Codecov by Sentry. |
pointerDown |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (2)
- src/index.tsx (4 hunks)
- src/interface.ts (1 hunks)
Additional context used
GitHub Check: codecov/patch
src/index.tsx
[warning] 538-538: src/index.tsx#L538
Added line #L538 was not covered by tests
[warning] 540-540: src/index.tsx#L540
Added line #L540 was not covered by tests
Additional comments not posted (3)
src/interface.ts (1)
107-107
: 代码更改已批准。添加新的操作类型
'pointDown'
符合 PR 的目标,即引入pointerDown
事件。这个改动正确地将新的操作类型添加到了现有的可能的字符串字面量集合中。命名约定与现有的操作类型保持一致。这个改动是小而局部的,不会影响类型定义的整体结构,也不会对使用ActionType
类型的现有代码引入任何破坏性变更。src/index.tsx (2)
559-559
: 看起来不错!添加的注释清晰地解释了单击/指针按下隐藏的特殊行为。
670-670
: 看起来很棒!将
onPointerDown
添加到传递的事件属性列表中,与新添加的处理onPointDown
事件的功能保持一致。
src/index.tsx
Outdated
// ======================= Action: PointDown ======================== | ||
const pointDownToShow = showActions.has('pointDown'); | ||
const pointDownToHide = hideActions.has('pointDown'); | ||
if (pointDownToShow || pointDownToHide) { | ||
cloneProps.onPointDown = (event: React.PointerEvent<HTMLElement>, ...args: any[]) => { | ||
if (openRef.current && pointDownToHide) { | ||
triggerOpen(false); // to hide | ||
} else if (!openRef.current && pointDownToShow) { | ||
setMousePosByEvent(event); | ||
triggerOpen(true); | ||
} | ||
// origin methods | ||
originChildProps.onPointDown?.(event, ...args); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
代码更改看起来不错!
新添加的代码正确地实现了处理 onPointDown
事件的功能。该逻辑检查是否启用了在指针按下事件上显示或隐藏组件的操作。如果是,它会为 cloneProps.onPointDown
分配一个新的事件处理程序。此处理程序根据当前状态和指定的操作来确定是触发打开还是关闭组件。
提醒:为新代码路径添加测试。
静态分析工具指出,添加的第 538 行和第 540 行未被测试覆盖。
您希望我生成测试代码还是开一个 GitHub issue 来跟踪此任务?
Tools
GitHub Check: codecov/patch
[warning] 538-538: src/index.tsx#L538
Added line #L538 was not covered by tests
[warning] 540-540: src/index.tsx#L540
Added line #L540 was not covered by tests
我看代码里写的是 onPointDown ? |
确实,有点久远了,我先 review 看看,连夜改 |
@enson0131 Take you time~ |
fix 了,确实是刚开始写错了 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (2)
- src/index.tsx (4 hunks)
- src/interface.ts (1 hunks)
Files skipped from review as they are similar to previous changes (1)
- src/interface.ts
Additional comments not posted (2)
src/index.tsx (2)
559-559
: 代码更改看起来不错!将
pointerDown
添加到可以在外部单击时隐藏组件的事件列表中,与添加pointerDown
事件处理的更改保持一致。它确保在用户使用pointerDown
事件在组件外部单击时隐藏组件。
670-670
: 代码更改看起来不错!将
onPointerDown
添加到传递给子组件的事件列表中,与添加pointerDown
事件处理的更改保持一致。它确保将onPointerDown
事件传递给子组件。
添加 pointerDown 事件比 click 事件更加适用大板触摸设备
Summary by CodeRabbit
新功能
pointerDown
动作类型,以支持更复杂的用户交互。文档