fix(notification): 修复 NotifyPlugin.close 错误触发 onCloseBtnClick 的问题 #5958
+21
−2
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
🤔 这个 PR 的性质是?
🔗 相关 Issue
修复了
NotifyPlugin.close()
会错误触发onCloseBtnClick
事件的问题。💡 需求背景和解决方案
问题背景:
onCloseBtnClick
事件本应仅在用户手动点击关闭按钮时触发。但在之前的实现中,通过代码调用NotifyPlugin.close()
方法同样会错误地触发该事件。这会导致开发者在onCloseBtnClick
回调中编写的、仅针对用户行为的逻辑被意外执行,从而引发潜在的 Bug。解决方案:
新增
onClose
事件,将程序化关闭和用户手动关闭的逻辑进行解耦。Notification
: 新增onClose
prop,并重构内部关闭逻辑,区分了用户点击 (handleCloseBtnClick
) 和程序化调用 (close
),确保只有前者触发onCloseBtnClick
事件。备注:
‘packages/components/notification/_example/plugin.vue’是为了演示这个场景,后续需要删除
📝 更新日志
tdesign-vue-next
fix(Notification)
: 调用NotifyPlugin.close()
将不再触发onCloseBtnClick
事件☑️ 请求合并前的自查清单