You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This issue occurs exclusively in version 4.9.2, downgrading to 4.9.1 resolves the issue.
When injecting any design token and calling .SetValue() with any element reference, the DesignToken class fails to inject the registered LibraryConfiguration causing an Object reference not set to an instance of an object exception to be thrown inside UrlFormatterExtensions.cs.
💻 Repro or Code Sample
Component:
@using Microsoft.FluentUI.AspNetCore.Components.DesignTokens
<div class="container"><FluentTextField @ref="Test" @bind-Value=Title></FluentTextField></div>
@code {[Parameter,EditorRequired]
public string Title {get;set;}=null!;
FluentTextField Test;[Inject]
private Density _density {get;set;}=default!;
protected override async Task OnAfterRenderAsync(boolfirstRender){if(firstRender){await _density.SetValueFor(Test.Element,10);StateHasChanged();}}}
I went ahead and checked out this repository to see if I could find the issue and I was able to locate the issue and confirm the fix locally.
It appears there was an existing DI constructor in DesignToken which set the IJSRuntime, but not the LibraryConfiguration which was introduced in 4.9.2.
I modified the constructor for DesignToken as well as the DesignTokenGenerator to add the DI for LibraryConfiguration for all design tokens:
TimonFeldmann
changed the title
fix: Missing LibraryConfiguring Injection in DesignToken.razor.cs
Fix For: Missing LibraryConfiguring Injection in DesignToken.razor.cs
Jul 21, 2024
🐛 Bug Report
This issue occurs exclusively in version 4.9.2, downgrading to 4.9.1 resolves the issue.
When injecting any design token and calling
.SetValue()
with any element reference, theDesignToken
class fails to inject the registeredLibraryConfiguration
causing anObject reference not set to an instance of an object
exception to be thrown insideUrlFormatterExtensions.cs
.💻 Repro or Code Sample
Component:
Startup:
🤔 Expected Behavior
Calling
.SetValue()
on anyDesignToken
should not throw a null reference exception.😯 Current Behavior
LibraryConfiguration
is injected asnull
intoDesignToken.razor.cs
causing a null reference exception when attempting to set anyDesignToken
value.🌍 Your Environment
The text was updated successfully, but these errors were encountered: