angular / angular/components

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

Ouverte
#28,601 1 commentaire 0 réactions 0 personnes assignées Voir sur GitHub
area: material/snack-bar P5
Langage dominant
TypeScript
Étoiles
25k
Forks
6.8k
Merge moyen
1 j 8 h
PR mergées (30 j)
91

Description

### 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):

Guide de contribution

Ouvrir le guide de contribution

Piste de recherche

Commencez par la reproduction StackBlitz liée, en particulier src/main.ts, et rechargez-la dans Firefox ou Safari pour confirmer les états dupliqués de la snackbar. Suivez le comportement de démarrage du composant racine et comparez-le avec l'affichage de la snackbar plus tard. C'est terminé lorsque la snackbar n'apparaît qu'une seule fois avec son animation de fade-in.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
angular, typescript
Domaine
frontend
Type d'issue
Bug
Difficulté
3/5
Temps estimé
1-2 jours
Activité
À l'abandon
Clarté
Plutôt claire
Accessibilité débutants
35/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.