-
Notifications
You must be signed in to change notification settings - Fork 363
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
fix: [Demo apps] Infinite rendering loop in TableOfContents #424
Comments
Oops, this got introduced with one of my latest changes. |
@andreisaperski locally your solution works on Server but not on Client. Have you tested on Client? Is it working for you there? |
Yeah, i check on Client (FluentUI.Demo.Client), Server (FluentUI.Demo.Server) and Hybrid (MAUI). Logger.LogInformation($"QueryDom [{NavigationManager.Uri} - {DateTime.Now:HH:mm:ss}]"); With commented out check - effectively without fix //if (AnchorsEqual(_anchors, newAnchors))
//{
// return;
//} the log reflects ~130 executions of QueryDom() (re-renders) per second: With uncommented check, the log shows that QueryDom() executes a few times after navigation When i uncommented check, i hit F5 and FluentUI.Demo.Client started with previously built version of FluentUI.Demo.Shared. I had to do Rebuild of FluentUI.Demo.Client to have it running with latest changes in FluentUI.Demo.Shared. Maybe you have the same situation - FluentUI.Demo.Client starts with FluentUI.Demo.Shared (dll) built before fix |
Yes, I see that it works in a sense that it is not running continuously with your fix. But it is also not showing the actual table of contents after reading the markdown file. And that is what we want it to do. |
Could you please point me to a page where it doesn't work. i checked markdown-based pages What's new?/Project setup/Code setup/Design tokens and ToC there matched with pages' structure. Also check that these pages raise OnRefreshTableOfContents, DemoMainLayout handles it and calls TableOfContents.Refresh() which in its turn calls QueryDom() |
For me it goes wrong on every page that loads Markdown to display contents, ie DesignTokens and CodeSetup |
🐛 Bug Report
OnAfterRenderAsync (in TableOfContents.razor.cs) calls QueryDom() which in its turn loads anchors and calls StateHasChanged() - rendering starts again.
💻 Repro or Code Sample
FluentUI.Demo.Client/FluentUI.Demo.Server in examples.
Browser's tab with https://www.fluentui-blazor.net/ consumes ~20% of CPU on my PC even if there's no any interaction (clicks/scroll)
🤔 Expected Behavior
Re-rendering doesn't happen all the time
😯 Current Behavior
TableOfContents keeps re-rendering without any reason.
💁 Possible Solution
Looks like QueryDom() should call StateHasChanged() only if anchors have changed e.g.:
Anchor record needs Equal implemented because of child anchors:
🔦 Context
🌍 Your Environment
The text was updated successfully, but these errors were encountered: