[dev-v5] Make browser native validation opt-in#4989
Open
vnbaaij wants to merge 3 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR makes browser-native constraint validation UI (Constraint Validation API bubbles/messages via reportValidity) opt-in for Fluent input components, aligning default behavior with Fluent UI styling while still allowing consumers to enable native browser UI via LibraryConfiguration.
Changes:
- Added
LibraryConfiguration.UseNativeConstraintValidationUiand plumbed it intoFluentInputBaseas a component parameter default. - Gated
reportValidityJS interop calls behind the new opt-in flag. - Updated/added unit tests to verify
reportValidityis (not) invoked depending on configuration, and documented the new option in the demo docs.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/Core/Components/Validation/FluentInputValidationDefaultsTests.cs | Adds new tests asserting default vs opt-in reportValidity invocation behavior. |
| tests/Core/Components/TextArea/FluentTextAreaTests.razor | Removes the unconditional reportValidity expectation test now that behavior is opt-in. |
| tests/Core/Components/Switch/FluentSwitchTests.razor | Removes the unconditional reportValidity expectation test now that behavior is opt-in. |
| src/Core/Infrastructure/LibraryConfiguration.cs | Introduces the UseNativeConstraintValidationUi opt-in library configuration flag. |
| src/Core/Components/Base/FluentInputBase.cs | Applies the library default to components and short-circuits ReportValidityAsync unless enabled. |
| examples/Demo/FluentUI.Demo.Client/Documentation/Components/Forms/Forms.md | Documents how to enable native constraint validation UI via AddFluentUIComponents configuration. |
|
✅ All tests passed successfully Details on your Workflow / Core Tests page. |
Summary - Unit Tests Code CoverageSummary
CoverageMicrosoft.FluentUI.AspNetCore.Components - 98.9%
Microsoft.FluentUI.AspNetCore.Components.Charts - 100%
Microsoft.FluentUI.AspNetCore.Components.Tests.Tools - 70.5%
|
dvoituron
requested changes
Jul 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When using the
FluentValidationMessage(introduced with RC4) we now also hook into the browser native validation (the Constrained Validation API). This means that when an input looses focus (not on submit!), it is checked against the set constraints and shows browser native UI (see image below)With this PR we make that behavior opt-in.
You opt-in by setting
UseNativeConstraintValidationUI=trueon theLibraryConfigurationwhen calling theAddFluentUIComponents()extension method inProgram.cs:Before
After
Note that you still get the red border on the input. That is part of the web component where it is applying the
:user-invalidstateUnit tests to validate whether the
reportValidityfunction is called, have been added.