-
Notifications
You must be signed in to change notification settings - Fork 26.2k
Angular 19: Issue with Style Flickering When Switching Views (ng serve) #59058
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
Comments
We also had this in our project. |
I just wanted to report this issue and have created a demo repository to reproduce it: https://github.com/otodockal/ng-host. In my case, the flickering occurs when combining styles declared in ng-host.mov |
I encounter the same issue. And it also strangely affects |
I am experiencing the same issue even with HMR off. |
@joewIST then it, perhaps, is a different bug and requires a different reproduction example. |
It is worth noticing that this issue does not occur in Firefox browser. Turning off hmr flag helps for me as well. |
We still get the flickering on Firefox (which occurs while the styles are loaded). The only difference is that on Firefox, once the styles have been loaded, they are not reloaded whenever the component is reused. On Edge/Chrome, they seem to be loaded every time the component is requested, which causes the flicker to occur a lot. For reference, this is only happening when a) a component is dynamically rendered (e.g. something in a dropdown that gets initialised when the dropdown is opened or b) a component is wrapped in an @if block and is only rendered after a user interaction (e.g. a loading state in a button). |
I have been able to remove the flickering, based on the asynchronous loading of styles, but for our project it only works when I set the "live-reload" flag to false. The "hmr" flag seems to have no impact. When I serve the application with this flag set, the styles are working as they did before upgrading to v19. Obviously, there is a cost with this, as the app requires a manual refresh for any changes to be reflected, so it would be good to have this fixed! Thanks |
@joewIST are you testing with |
@hakimio I have tried it with both and neither have any impact. Like I said, the only thing that has made a difference is turning live reload off... |
I also created a similar issue #59129. |
I have the same issue. But it's the smallest of the problem - the key problem is that now ngAfterViewInit is called before the styles of component are loaded. It's very huge impact on the application. I've created separated issue: "Angular 19: Component initialization logic is broken by HMR #59151". |
For Angular > 19 schema hmr option was ignored, it was impossible to disable hmr as default value changed in ng19 angular/angular#59058
FYI |
For Angular > 18 schema hmr option was ignored, it was impossible to disable hmr and default value changed in ng19 angular/angular#59058 <!-- Please make sure you have read the submission guidelines before posting an PR --> <!-- https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr --> <!-- Please make sure that your commit message follows our format --> <!-- Example: `fix(nx): must begin with lowercase` --> <!-- If this is a particularly complex change or feature addition, you can request a dedicated Nx release for this pull request branch. Mention someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they will confirm if the PR warrants its own release for testing purposes, and generate it for you if appropriate. --> ## Current Behavior <!-- This is the behavior we have today --> ## Expected Behavior <!-- This is the behavior we should expect with the changes in this PR --> ## Related Issue(s) <!-- Please link the issue being fixed so it gets closed when this is merged. --> Fixes #
- Basic update to Angular 19 - Minor SCSS updates for deprecated lighten/darken - Moved the showing of the responsive overlay to config (off by default) - Removed yarn file (redundant - left over from long past experiments) - Temporarily disabled HMR due to to an open issue (angular/angular#59058)
Hi Everyone i got the same Issue even after Deployment using |
Also having this issue. |
Important To help us investigate, please provide the specific version of the software you're using. This will help us pinpoint the issue more effectively |
Using v18 on my mac without nx, it happens when the main page is loading. After the loading, whenever I press refresh (f5) it also happens |
Under here I made a minimal reproduction when using the flag All details of my OS, etc I wrote already under: Update: When building it and running it from a server its not happening. Its purly in my case solved by not using hmr. NOTE: On my website, when transitioning pages I have the hmr issue as well. So this is NOT only when opening the page for the first time and refreshing but also when navigating trough the pages e.g. home, about, etc. |
I spent so far 7h on this, updating node version, adding back standalone, making a open source version so someone can reproduce it, writing down everything. I don't mind the time. However I'm afraid of the frameworks reputation cause people will update, devs will experience this issue and be lost. Maybe keep v18 again as I did in the first place. I get that the milions of tests, that google has, has not catched this issue cause its a purly developer experience issue but on the other hand I never ever saw a developer updating the hole project and then first running its tests before opening the page once and looking at it. Maybe at least in some projects the tests have to be also executed serving the project not building it then this bug would have been noticed. Please revert the HMR as a default or fix the issue but this can not stay until v20 like this, not even until 19.1 I think. |
I have Nx v20, yesterday updated using latest flag. Had the issue as everyone else. So its not true that its ignoring it. At least not right now. |
I am experiencing the same issue. Since I updated my project to Angular v19, I am experiencing style flickering for a split second, everytime I am navigating my application using the internal angular router. It also happens when refreshing the app with F5. Disabling HMR fixes the issue, although I'd really like to use it. |
i openened an issue, but was immidiatly closed because of duplication.... there, i point out source/underlying issue & quick workaround without compromising on project, enjoy |
This late/lazy HMR style loading breaks
The demo project with steps to reproduce the issue: Material Sidnav style HMR bug @clydin it's crazy that some 6 year old bugs are not fixed because the fix causes Google internal tests to break. Yet it feels like this new |
The issue went away for me when I turned hmr off. |
When "hmr": off is added to the angular.json file, the issue is resolved,
but it negatively impacts the application's performance. For example, when
opening a modal, there is a noticeable delay.
…On Thu, Jan 16, 2025 at 1:15 AM James Tu (Starz) ***@***.***> wrote:
The issue went away for me when I turned hmr off.
You can do it via ng serve --hmr=false
or update your angular.json
"hmr": off
—
Reply to this email directly, view it on GitHub
<#59058 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ALEDTY2T7YKOFIW5ULBKGF32K23EVAVCNFSM6AAAAABTBIVW2WVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKOJTG44TKNJSGU>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
As an alternative you can change your builder in angular.json to "builder": "@angular-devkit/build-angular:browser". And the flickering will disappear. |
Thanks for reporting this issue. Luckily, it has already been fixed in one of the recent releases. Please update to the most recent version to resolve the problem. |
For Angular > 18 schema hmr option was ignored, it was impossible to disable hmr and default value changed in ng19 angular/angular#59058 <!-- Please make sure you have read the submission guidelines before posting an PR --> <!-- https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr --> <!-- Please make sure that your commit message follows our format --> <!-- Example: `fix(nx): must begin with lowercase` --> <!-- If this is a particularly complex change or feature addition, you can request a dedicated Nx release for this pull request branch. Mention someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they will confirm if the PR warrants its own release for testing purposes, and generate it for you if appropriate. --> ## Current Behavior <!-- This is the behavior we have today --> ## Expected Behavior <!-- This is the behavior we should expect with the changes in this PR --> ## Related Issue(s) <!-- Please link the issue being fixed so it gets closed when this is merged. --> Fixes #
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Which @angular/* package(s) are the source of the bug?
Don't known / other
Is this a regression?
Yes
Description
Hello everyone,
The problem occurs when starting the project via npm run start (i.e. ng serve). When the project is built, the problem does not occur.
I'd like to inform you about a problem I've encountered after updating to Angular 19. When navigating from one view to another and back, I've noticed a flickering effect related to the styles of a specific component. As the component loads, it appears without any styles for a split second before the styles are applied and everything returns to normal.
This issue did not occur in Angular 18.
How to reproduce the problem:
Create a new project in Angular 19.
Create two routable components, e.g., view1 and view2.
Add HTML elements to each component, such as
<h1>, <p>
, and a with a routerLink navigating between view1 and view2.Add styles to these components, like background, font-size, etc.
Run the application and navigate to the main page. If you refresh the page directly or using the refresh button, everything works correctly.
Navigate using the button with routerLink to the second view and back. You'll notice that for a moment, the components are displayed without styles, and then the styles load.
Additional Information:
Browser: Google Chrome 131.0.6778.70
Example in stackblitz: https://stackblitz.com/edit/stackblitz-starters-rb8wat
Seems like this bug is bound to the HMR of stylesheets cause once built, there is no bug anymore.
Please provide a link to a minimal reproduction of the bug
https://stackblitz.com/edit/stackblitz-starters-rb8wat
Please provide the exception or error you saw
Please provide the environment you discovered this bug in (run
ng version
)Anything else?
No response
The text was updated successfully, but these errors were encountered: