igniteui-angular
igniteui-angular copied to clipboard
[IgxOverlay] width for igx-snackbar is not set correctly when it is initially shown
Description
When IgxSnackbar is initially shown, the width is not set correctly. If the snackbar is then closed and opened again, it receives the correct size.
- igniteui-angular version: 13.1.x
- browser: all
Steps to reproduce
- Open this demo.
- The initial appearance of the snackbar is broken.
- Close the snackbar and open it again by clicking on any of the above buttons.
- Snackbar is displayed correctly.
Result
IgxSnackbar is not shown correctly initially.
Expected result
IgxSnackbar should be shown with correct size at all times.
Attachments
This behavior could be observed in the attachment below:
There has been no recent activity and this issue has been marked inactive.
There has been no recent activity and this issue has been marked inactive.
There has been no recent activity and this issue has been marked inactive.
The reason why this happens is because the snackbar is opened in the ngOnInit
lifecycle hook, which is called before Angular has fully initialized the component's view. What I would suggest is to open it in the ngAfterViewInit
lifecycle hook.