Skip to content

Blazor VirtualScroll throwing exception when used with double-bound field and @key keyword #27382

Closed
@bancroftway

Description

@bancroftway

I have double-bound field inside a VirtualScroll component and the item template has @key keyword

                  <tbody>
                    <Virtualize Context="forecast" ItemSize="50" ItemsProvider="@LoadItems">
                        <ItemContent>
                            <tr @key="forecast.Id">
                                <td>@forecast.Date.ToShortDateString()</td>
                                <td>
                                    <InputNumber class="form-control text-center input-sm" @bind-Value="forecast.TemperatureC" />
                                </td>
                                <td>
                                    @forecast.TemperatureF
                                </td>
                                <td>@forecast.Summary</td>
                            </tr>
                        </ItemContent>
                 </Virtualize>
                </tbody>

when the field is edited and without tabbling off the field, an exception is thrown:

Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100]
      Unhandled exception rendering component: Event 96 is already tracked
      Error: Event 96 is already tracked
          at e.update (https://localhost:44362/_framework/blazor.webassembly.js:1:42587)
          at e.setListener (https://localhost:44362/_framework/blazor.webassembly.js:1:40180)
          at e.applyAttribute (https://localhost:44362/_framework/blazor.webassembly.js:1:36469)
          at e.applyEdits (https://localhost:44362/_framework/blazor.webassembly.js:1:32895)
          at e.updateComponent (https://localhost:44362/_framework/blazor.webassembly.js:1:31876)
          at Object.t.renderBatch (https://localhost:44362/_framework/blazor.webassembly.js:1:11924)
          at Object.window.Blazor._internal.renderBatch (https://localhost:44362/_framework/blazor.webassembly.js:1:61510)
          at Object.w [as invokeJSFromDotNet] (https://localhost:44362/_framework/blazor.webassembly.js:1:64032)
          at _mono_wasm_invoke_js_blazor (https://localhost:44362/_framework/dotnet.5.0.0-rc.2.20475.5.js:1:190396)
          at wasm_invoke_iiiiii (<anonymous>:wasm-function[5611]:0xdda74)
Microsoft.JSInterop.JSException: Event 96 is already tracked

A reproduction is here: https://github.com/bancroftway/blazorissuesrepro/tree/vscrollalreadytracked

A brief video showing the error is here: https://www.youtube.com/watch?v=XUUhTaIPodA

Metadata

Metadata

Labels

affected-mediumThis issue impacts approximately half of our customersarea-blazorIncludes: Blazor, Razor ComponentsbugThis issue describes a behavior which is not expected - a bug.feature-blazor-virtualizationThis issue is related to the Blazor Virtualize componentseverity-majorThis label is used by an internal tool

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions