fluentui-blazor: Stack overflow in main web-components library when using FluentCard together with FluentDesignSystemProvider

πŸ› Bug Report

This was a tricky one to isolate!

When FluentDesignSystemProvider (i.e. in Routes.razor) is in use, adding a FluentCard component to any pages results in the following exception, visible in the developer tools:

web-components-v2.5.16.min.js:21  Uncaught RangeError: Maximum call stack size exceeded
    at d (web-components-v2.5.16.min.js:21:88279)
    at b (web-components-v2.5.16.min.js:21:89056)
    at Kn (web-components-v2.5.16.min.js:21:89167)
    at Object.evaluate (web-components-v2.5.16.min.js:21:98645)
    at c.<anonymous> (web-components-v2.5.16.min.js:21:98786)
    at c.observe (web-components-v2.5.16.min.js:1:4877)
    at uo.handleChange (web-components-v2.5.16.min.js:16:93313)
    at c.notify (web-components-v2.5.16.min.js:1:3138)
    at c.call (web-components-v2.5.16.min.js:1:5462)
    at u.notify (web-components-v2.5.16.min.js:1:3138)

If multiple cards are in place, this causes serious performance issues and breaks some behavior (i.e. theming seems to stop working after this exception).

πŸ’» Repro or Code Sample

https://github.com/kzu/fluentui-bug/

Steps:

  1. Clone repo

  2. Run. If running with the VS debugger, the javascript exception will be visible in the Debug output pane, otherwise, it can be seen in the browser developer tools

  3. Remove or comment out the FluentDesignSystemProvider from Routes.razor => the error dissapears

  4. Alternatively, remove or comment out the FluentCard from Home.razor (while keeping the FluentDesignSystemProvider) => likewise, the error dissapears.

πŸ€” Expected Behavior

No exceptions should happen because of using either the FluentDesignSystemProvider or the FluentCard.

🌍 Your Environment

  • Browser: Microsoft Edge
  • Web-components: web-components-v2.5.16.min.js
  • FluentUI: Microsoft.FluentUI.AspNetCore.Components v4.1.1

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 17 (2 by maintainers)

Most upvoted comments

I’ve switched for now to the new FluentDesignTheme which works fine in combination with FluentCard.

And for the stroke (which I also needed), I’m just using the design token around the routes:

    <FluentDesignTheme CustomColor="@AppConstants.AccentColor" StorageName="myapp" />
    <Microsoft.FluentUI.AspNetCore.Components.DesignTokens.StrokeWidth Value="0">
        <Routes />
    </Microsoft.FluentUI.AspNetCore.Components.DesignTokens.StrokeWidth>

With this combination, I’m effectively unblocked for now πŸ˜ƒ

@kzu @vnbaaij That could be interesting to add a new attribute to the FluentDesignTheme to specify all other DesignTokens properties. Example:

<FluentDesignTheme StorageName="myapp" DesignToken="@Token " />

@code
{
    private DesignThemeToken Token = new()
    {
        StrokeWidth = 1,
        Density = 0,
        ...
    };
}

V4 is .NET 8 only. It has a new name(space) : Microsoft.FluentUI.AspNetCore.Components. Upgrading is not too hard but also not next, next, finish. See the docs site

Daniel (@kzu), glad you are unblocked! I’ll keep this one open to track the issue in the fluent repo.

Surely here it is

<!DOCTYPE html>
<html lang="en">

<head>
    <script type="module" src="https://unpkg.com/@fluentui/web-components"></script>
</head>

<body>
    <fluent-design-system-provider accent-base-color="#682079">
        <div>
            <!-- comment the fluent-card tag for the code to work -->
            <fluent-card>
                Hello World
            </fluent-card>
            <br />
            <fluent-button appearance="accent" >
                Test
            </fluent-button>
        </div>
    </fluent-design-system-provider>
</body>

</html>

Thanks @pk9r327 for chasing that down!

@kzu as it is a bug in the underlying web components, we can’t fix it here (before v4.2) . I’ll raise an issue in the web components repo on this.

i tried @fluentui/web-components and it probably had the same problem. I see it happening when fluent-design-system-provider sets the accent-base-color value and the fluent-card tag is inside a div tag.

image