Fix FluentKeyCodeProvider error on using browser autocomplete with InputText#5030
Open
najlot wants to merge 1 commit into
Open
Fix FluentKeyCodeProvider error on using browser autocomplete with InputText#5030najlot wants to merge 1 commit into
najlot wants to merge 1 commit into
Conversation
Author
|
@microsoft-github-policy-service agree |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR hardens the FluentKeyCode JavaScript interop against malformed/partial keyboard events (e.g., events missing numeric/boolean properties), preventing System.Text.Json deserialization failures when Blazor receives the event payload.
Changes:
- Normalize keyboard event fields (
keyCode, modifier flags,location,repeat,key) before invoking .NET (invokeMethodAsync) to ensure stable argument types. - Add a Playwright integration test + minimal Razor page that reproduces a “keydown event missing properties” scenario and asserts the component reports default values instead of throwing.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| tests/Integration/Components/KeyCode/FluentKeyCodeTests.cs | Adds an integration test that dispatches a malformed keydown event and verifies default output values. |
| tests/Integration/Components/KeyCode/Examples/MalformedKeyboardEventPage.razor | Adds a dedicated test page wiring FluentKeyCode to an input and rendering observed event values for assertions. |
| src/Core/Components/KeyCode/FluentKeyCode.razor.ts | Normalizes event argument types before JS→.NET invocation to avoid JSON token type errors. |
dvoituron
reviewed
Jul 20, 2026
dvoituron
left a comment
Collaborator
There was a problem hiding this comment.
Need more time to validate 😊
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.
Pull Request
📖 Description
Hello everyone!
I've been trying to get FluentUI Blazor into an existing Blazor WebAssembly application.
After I've added FluentUI.Blazor like it is described in
https://v5.fluentui-blazor.net/installation
i've got an error as I tried to log in.
So there is a fix for that.
Stack trace I've got:
Message=
Source=
StackTrace:
at System.Text.Json.ThrowHelper.ThrowInvalidOperationException_ExpectedNumber(JsonTokenType tokenType)
at System.Text.Json.Utf8JsonReader.TryGetInt32(Int32& value)
at System.Text.Json.Utf8JsonReader.GetInt32()
at System.Text.Json.Serialization.Converters.Int32Converter.Read(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options)
at System.Text.Json.Serialization.JsonConverter
1[[System.Int32, System.Private.CoreLib, Version=10.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, Int32& value, Boolean& isPopulatedValue) at System.Text.Json.Serialization.JsonConverter1[[System.Int32, System.Private.CoreLib, Version=10.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].ReadCore(Utf8JsonReader& reader, Int32& value, JsonSerializerOptions options, ReadStack& state)Exception_EndOfInnerExceptionStack
at System.Text.Json.ThrowHelper.ReThrowWithPath(ReadStack& state, Utf8JsonReader& reader, Exception ex)
at System.Text.Json.Serialization.JsonConverter
1[[System.Int32, System.Private.CoreLib, Version=10.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].ReadCore(Utf8JsonReader& reader, Int32& value, JsonSerializerOptions options, ReadStack& state) at System.Text.Json.Serialization.Metadata.JsonTypeInfo1[[System.Int32, System.Private.CoreLib, Version=10.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].Deserialize(Utf8JsonReader& reader, ReadStack& state)at System.Text.Json.Serialization.Metadata.JsonTypeInfo`1[[System.Int32, System.Private.CoreLib, Version=10.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].DeserializeAsObject(Utf8JsonReader& reader, ReadStack& state)
at System.Text.Json.JsonSerializer.ReadAsObject(Utf8JsonReader& reader, JsonTypeInfo jsonTypeInfo)
at System.Text.Json.JsonSerializer.Deserialize(Utf8JsonReader& reader, Type returnType, JsonSerializerOptions options)
at Microsoft.JSInterop.Infrastructure.DotNetDispatcher.ParseArguments(JSRuntime jsRuntime, String methodIdentifier, String arguments, Type[] parameterTypes)
at Microsoft.JSInterop.Infrastructure.DotNetDispatcher.InvokeSynchronously(JSRuntime jsRuntime, DotNetInvocationInfo& callInfo, IDotNetObjectReference objectReference, String argsJson)
at Microsoft.JSInterop.Infrastructure.DotNetDispatcher.BeginInvokeDotNet(JSRuntime jsRuntime, DotNetInvocationInfo invocationInfo, String argsJson)
at w.endInvokeDotNetFromJS (http://localhost:5270/_framework/blazor.webassembly.w3qd1tpl0e.js:1:4504)
at Object.tn [as endInvokeDotNetFromJS] (http://localhost:5270/_framework/blazor.webassembly.w3qd1tpl0e.js:1:59313)
at http://localhost:5270/_framework/dotnet.runtime.web2r9gqbh.js:3:34587
at Mc (http://localhost:5270/_framework/dotnet.runtime.web2r9gqbh.js:3:175837)
at http://localhost:5270/_framework/dotnet.native.u31nt9bth6.wasm:wasm-function[298]:0x1f797
at http://localhost:5270/_framework/dotnet.native.u31nt9bth6.wasm:wasm-function[222]:0x1ca98
at http://localhost:5270/_framework/dotnet.native.u31nt9bth6.wasm:wasm-function[213]:0xebe7
at http://localhost:5270/_framework/dotnet.native.u31nt9bth6.wasm:wasm-function[256]:0x1d974
at http://localhost:5270/_framework/dotnet.native.u31nt9bth6.wasm:wasm-function[3231]:0xf1888
at http://localhost:5270/_framework/dotnet.native.u31nt9bth6.wasm:wasm-function[2553]:0xc7139
🎫 Issues
No issue created as there is the fix.
👩💻 Reviewer Notes
There is what I've done:

📑 Test Plan
I've got an simple example app where the issue can be reproduced:
example_app.zip
✅ Checklist
General
Component-specific
⏭ Next Steps