-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
fix: Sender skill closable.onClose not triggered when deleting skill via Backspace #1964
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
22b114b
523a199
c12fd52
3b944c1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -525,6 +525,10 @@ const SlotTextArea = React.forwardRef<SlotTextAreaRef>((_, ref) => { | |
| if (skillKey) { | ||
| e.preventDefault(); | ||
| removeSkill(); | ||
| // 与点击关闭行为保持一致,删除后补发 closable.onClose | ||
| if (skill?.closable && typeof skill.closable === 'object') { | ||
| skill.closable.onClose?.(e as unknown as React.MouseEvent<HTMLDivElement>); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Casting a Since
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Addressed in 523a199 — took the wider-type route: |
||
| } | ||
| return true; | ||
| } | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| } | ||
|
|
||
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.
Using
toBeDefined()onref.currentandskillDomis a weak assertion becausenullis considered defined in Jest. SincequerySelectorreturnsnullwhen an element is not found,expect(skillDom).toBeDefined()will pass even if the element does not exist.We should use
not.toBeNull()for the ref andtoBeInTheDocument()for the DOM element to ensure they actually exist and are rendered correctly.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.
Fixed in 523a199 —
not.toBeNull()for the ref andtoBeInTheDocument()for the skill element.