fix: [v5] FluentTextInput throws from ElementInternals during .NET 11 enhanced form navigation
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 73/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- csharp, javascript
Research direction
Start with the FluentTextInput custom element’s setCustomValidity implementation, identified in the browser stack as coming from Microsoft.FluentUI.AspNetCore.Components.lib.module.js, and trace its validation lifecycle through ValidationEngine.ts and BlazorAdapter.ts. Reproduce with the supplied .NET 11 static SSR form and enhanced-navigation steps. Done when clearing custom validity no longer throws during teardown and the control still supports client validation; the issue also requests a regression test.
Written by the indexing model from the issue text.
Description
🐛 Bug Report
💻 Repro or Code Sample
Use Fluent UI Blazor 5.1.0 with .NET 11 in a statically rendered Blazor Web App.
Render an EditForm with DataAnnotationsValidator and a FluentTextInput bound to a model property with a client validation rule:
<EditForm Model="Input" FormName="profile" OnValidSubmit="SubmitAsync" method="post">
<DataAnnotationsValidator />
<FluentTextInput
Name="Input.PhoneNumber"
@bind-Value="Input.PhoneNumber"
Label="Phone number" />
<FluentButton Type="ButtonType.Submit">Save</FluentButton>
</EditForm>
private sealed class InputModel
{
[Phone]
[Display(Name = "Phone number")]
public string? PhoneNumber { get; set; }
}
- Open the page through static SSR.
- Navigate away using Blazor enhanced navigation.
- Observe the browser console while the enhanced-navigation DOM update removes the previous page.
I reproduced this on an account profile page by navigating away from /Account/Manage.
A temporary workaround is:
<DataAnnotationsValidator DisableClientValidation="true" />
DataAnnotations validation continues to run server-side, but ASP.NET Core doesn't register the Fluent custom element with its browser validation adapter.
🤔 Expected Behavior
FluentTextInput should participate in ASP.NET Core's enhanced client validation without throwing when the form page is removed from the DOM.
Calling setCustomValidity('') should clear custom validity rather than leave customError active with an empty validation message.
😯 Current Behavior
Enhanced navigation throws:
Uncaught TypeError: Failed to execute 'setValidity' on 'ElementInternals':
The second argument should not be empty if one or more flags in the first argument are true.
Stack:
at HTMLElement.setCustomValidity (Microsoft.FluentUI.AspNetCore.Components.lib.module.js)
at Qs.unregisterElement (ValidationEngine.ts:69:15)
at HTMLElement.teardown (BlazorAdapter.ts:133:16)
at HTMLElement.disconnectedCallback (BlazorAdapter.ts:98:12)
at treatAsDeletion (DomSync.ts:243:16)
at synchronizeDomContentCore (DomSync.ts:137:11)
In .NET 11, the client validation adapter locates the form control by its name attribute. For FluentTextInput, this finds the <fluent-text-input> form-associated custom-element host. During enhanced-navigation teardown, ASP.NET Core calls:
element.setCustomValidity('');
The Fluent implementation currently calls ElementInternals.setValidity with an active custom-error flag even when the supplied message is empty:
setCustomValidity(e) {
this.elementInternals.setValidity({ customError: true }, e);
this.reportValidity();
}
Chromium rejects the resulting setValidity({ customError: true }, '') call.
💁 Possible Solution
When clearing custom validity, pass a false/empty validity state and no non-empty message requirement. For example, only set customError when the message is nonempty and let an empty call clear the custom validity state.
Please also consider adding a .NET 11 static SSR / enhanced-navigation regression test using a form-associated FluentTextInput and DataAnnotationsValidator.
Related: microsoft/fluentui#28724. That older web-components report describes the same ElementInternals.setValidity empty-message exception and was soft-closed in 2024. The .NET 11 enhanced client-validation lifecycle provides a current, reproducible trigger for the issue.
I’m willing to help with a minimal reproduction or validate a fix.
🔦 Context
The application uses Fluent UI Blazor controls for Identity account-management forms. The exception interrupts enhanced-navigation DOM synchronization when navigating away from a form page, resulting in a browser-console error and potentially incomplete enhanced-navigation cleanup.
🌍 Your Environment
- OS & Device: Windows 11 26H2 (build 26300), 64-bit PC
- Browser: Microsoft Edge 158.0.4370.45
- .NET SDK: 11.0.100
- ASP.NET Core / Blazor: 11.0.0
Microsoft.FluentUI.AspNetCore.Components: 5.1.0- Rendering model: Blazor Web App, static SSR with enhanced navigation
- Dominant language
- C#
- Stars
- 4.9k
- Forks
- 500
- Avg merge
- 15h 28m
- Merged PRs (30d)
- 58
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from microsoft/fluentui-blazor
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
microsoft/fluentui-blazor#5684 ·
Maintainers usually reply within 1 day
-
fix: option list stays open after a mouse pick in single-select FluentAutocompletePossibly taken @dvoituron claimed this 1 day ago. Open
microsoft/fluentui-blazor#5715 · 1 assignee ·
Maintainers usually reply within 1 day
-
Difficulty 3/5 1-2 days Newbie friendliness 56/100
microsoft/fluentui-blazor#5711 ·
Maintainers usually reply within 1 day
-
Difficulty 3/5 1-2 days Newbie friendliness 68/100
microsoft/fluentui-blazor#5707 ·
Maintainers usually reply within 1 day
-
fix: [v5] FluentValidationMessage icon shrinks when the validation message wrapsPossibly taken @vnbaaij claimed this 2 days ago. Open
microsoft/fluentui-blazor#5703 · 1 comment · 1 assignee ·
Maintainers usually reply within 1 day
All issues in microsoft/fluentui-blazor
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
[BUG] speech tts synthesize rejects valid locales such as fil-PH, yue-CN and sr-Latn-RS in --languagePossibly taken @Shizoqua claimed this today. OpenAzure.Mcp.Server needs-triage
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 2 days
-
Project dependencies are outdatedPossibly taken @yasmoradi claimed this today. Opendependencies
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
bitfoundation/bitplatform#15616 ·
Maintainers usually reply within 1 day
-
:watch: Not Triaged Pri3
Difficulty 1/5 Under an hour Newbie friendliness 91/100
Maintainers usually reply within 1 day
-
area-controls-shell platform/android
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
dotnet/maui#41304 · 1 reaction ·
Maintainers usually reply within 1 day