-
-
Notifications
You must be signed in to change notification settings - Fork 363
fix(Message): should clear when use same option #6513
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
Conversation
Reviewer's GuideThis PR refactors the Message component to reuse existing message entries when invoked with the same options—canceling any pending animations to prevent duplicates—and updates the sample page to correct message color and auto-hide behavior. Class diagram for updated Message item management in Message.razor.jsclassDiagram
class Message {
+items: Array<MessageItem>
+show(id, msgId)
}
class MessageItem {
+el
+animationId
}
Message o-- "*" MessageItem: contains
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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.
Hey @ArgoZhang - I've reviewed your changes - here's some feedback:
- Instead of using msg.items.pop(), remove the specific msgItem (e.g. via filter or splice) so you don’t accidentally drop the wrong entry when multiple messages are active.
- You cancel only the animation frame for an existing msgItem but not the auto-hide timeout—consider storing the hideHandler on msgItem and clearing it when reusing the same message to prevent stale timeouts from firing.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Instead of using msg.items.pop(), remove the specific msgItem (e.g. via filter or splice) so you don’t accidentally drop the wrong entry when multiple messages are active.
- You cancel only the animation frame for an existing msgItem but not the auto-hide timeout—consider storing the hideHandler on msgItem and clearing it when reusing the same message to prevent stale timeouts from firing.
## Individual Comments
### Comment 1
<location> `src/BootstrapBlazor/Components/Message/Message.razor.js:23` </location>
<code_context>
+ msg.items.push(msgItem)
+ }
+ if (msgItem.animationId) {
+ cancelAnimationFrame(msgItem.animationId);
+ }
+
</code_context>
<issue_to_address>
Consider resetting animationId after cancelAnimationFrame.
Setting msgItem.animationId to null or undefined after cancellation clarifies its state and helps prevent accidental reuse.
</issue_to_address>
<suggested_fix>
<<<<<<< SEARCH
if (msgItem.animationId) {
cancelAnimationFrame(msgItem.animationId);
}
=======
if (msgItem.animationId) {
cancelAnimationFrame(msgItem.animationId);
msgItem.animationId = null;
}
>>>>>>> REPLACE
</suggested_fix>
### Comment 2
<location> `src/BootstrapBlazor/Components/Message/Message.razor.js:51` </location>
<code_context>
const hideHandler = setTimeout(function () {
clearTimeout(hideHandler);
- // remove Id
msg.items.pop();
if (msg.items.length === 0) {
- // call server method prepare remove dom
</code_context>
<issue_to_address>
Using pop() may not remove the intended message item.
msg.items.pop() removes the last item, which may not be the correct message if multiple are present. Remove the specific msgItem to ensure accuracy.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6513 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 714 714
Lines 31387 31387
Branches 4430 4430
=========================================
Hits 31387 31387
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Link issues
fixes #6512
Summary By Copilot
Regression?
Risk
Verification
Packaging changes reviewed?
☑️ Self Check before Merge
Summary by Sourcery
Refactor the message display logic to properly clear and update existing message items when reusing the same option, cancel pending animations, and improve the sample usage to reflect the updated behavior.
Bug Fixes:
Enhancements: