angular / angular/components

bug(snackbar): Snackbar appears twice when loading on app start

未关闭
#28,601 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
area: material/snack-bar P5
主要语言
TypeScript
星标
25k
派生
6.8k
平均合并
1 天 8 小时
30 天内合并 PR
91

描述

### Is this a regression?

- [ ] Yes, this behavior used to work in the previous version

### The previous version in which this bug was not present was

_No response_

### Description

Snackbar appears twice - once without animation, and once with. I could only see this when showing the snackbar in my root component. Please manually scrub the videos to see the two states.

https://github.com/angular/components/assets/4698762/1a0fe6a8-2c2b-4489-b18e-97208b79d1b9

https://github.com/angular/components/assets/4698762/f71b3034-6fbe-4e61-aea2-b99e8a49b47d

Showing snackbar later works fine, as seen on docs: https://material.angular.io/components/snack-bar/examples.

### Reproduction

StackBlitz link: https://stackblitz.com/edit/stackblitz-starters-shuyqd?file=src%2Fmain.ts

Steps to reproduce:

1. Load snackbar in root component
2. Reload

### Expected Behavior

Snackbar should appear once, gracefully with fade-in animation. It does so when not loading in root component.

### Actual Behavior

Snackbar appears once without animation and then fade-in animation kicks in.

### Environment

- Angular: 17.2.1
- CDK/Material: 17.2.0
- Browser(s): Consistently on Firefox and Safari, sometimes on Chrome
- Operating System (e.g. Windows, macOS, Ubuntu):

贡献指南

打开贡献指南

调研方向

从链接的 StackBlitz 复现开始,尤其检查 src/main.ts,并在 Firefox 或 Safari 中重新加载它,以确认 snackbar 状态重复。跟踪根组件的启动行为,并将其与稍后显示 snackbar 的情况进行比较。当 snackbar 仅显示一次并带有其淡入动画时,即表示完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
angular, typescript
领域
frontend
Issue 类型
缺陷
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。