microsoft / fluentui-blazor

Microsoft Fluent UI Blazor components library. For use with ASP.NET Core Blazor applications
https://www.fluentui-blazor.net
MIT License
3.83k stars 372 forks source link

fix: Null reference exception when pressing clear button in FluentAutocomplete #2020

Closed yspanj closed 6 months ago

yspanj commented 6 months ago

🐛 Bug Report

Pressing the clear button of the Fluent autocomplete results in a null reference exception.

💻 Repro or Code Sample

🤔 Expected Behavior

Selection should be cleared.

😯 Current Behavior

Null reference exception with the following stack trace.

blazor.web.js:1  [2024-05-07T14:56:29.400Z] Error: Microsoft.JSInterop.JSException: Could not find 'focusOn' ('focusOn' was undefined).
Error: Could not find 'focusOn' ('focusOn' was undefined).
    at https://localhost:7060/_framework/blazor.web.js:1:734
    at Array.forEach (<anonymous>)
    at l.findFunction (https://localhost:7060/_framework/blazor.web.js:1:702)
    at b (https://localhost:7060/_framework/blazor.web.js:1:5445)
    at https://localhost:7060/_framework/blazor.web.js:1:3238
    at new Promise (<anonymous>)
    at y.beginInvokeJSFromDotNet (https://localhost:7060/_framework/blazor.web.js:1:3201)
    at gn._invokeClientMethod (https://localhost:7060/_framework/blazor.web.js:1:62841)
    at gn._processIncomingData (https://localhost:7060/_framework/blazor.web.js:1:60316)
    at connection.onreceive (https://localhost:7060/_framework/blazor.web.js:1:53957)
   at Microsoft.JSInterop.JSRuntime.InvokeAsync[TValue](Int64 targetInstanceId, String identifier, Object[] args)
   at Microsoft.JSInterop.JSObjectReferenceExtensions.InvokeVoidAsync(IJSObjectReference jsObjectReference, String identifier, Object[] args)
   at Microsoft.FluentUI.AspNetCore.Components.FluentAutocomplete`1.OnClearAsync() in /_/src/Core/Components/List/FluentAutocomplete.razor.cs:line 473
   at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task)
   at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task)
   at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle, ComponentState owningComponentState)

🔦 Context

This only seems to happen on a debug build.

https://github.com/microsoft/fluentui-blazor/assets/124144490/8926d686-5ca4-498f-a1dc-0fad56a22a4d

🌍 Your Environment

dvoituron commented 6 months ago

Without seeing an example of reproducible code or a repo, we don't know how to do anything.

focusOn is a javascript method included in the FluentAutocomplete.razor.js file. Can you reload the page via Ctrl+F5 (to clear the cache) or have you checked that you are developing using the "Interactive" RenderMode?

vnbaaij commented 6 months ago

Closing due to inactivity.