Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

Razor components not going away when condition not met

$
0
0

I have a custom Razor component - that works great - the first time. This code here uses it. And when you have no items - you get a box in the corner saying items = 0. When you do the search and there are items, the item selection panel appears like magic. All good.

The problem is: if I then clear the items - ie _items = [] - then the panel never goes away, it actually says in the panel item length 0, so it's like the if only works once or something.

Also, when I set items to something, the "check" panel never goes away.

@if (_items.Length > 1){<DashboardGridPanel Title="Select an item" X1="1" Y1="@(searchHeight + 1)" X2="4" Y2="@(13 - searchHeight)"><p>items length @(_items.Length) </p><div class="items-container">            @foreach (var item in _items)            {<div class='item-selection @(_selected == item ? "selected" : "")'                     @onclick="() => _selected = item"><span class="item-database">@item.DatabaseName</span><span class="item-type">@item.Type</span><span class="item-key">@item.DisplayKey</span></div>            }</div></DashboardGridPanel>}else{<DashboardGridPanel Title="Check" X1="10" Y1="10" X2="12" Y2="12"><p>items length = @(_items.Length)</p>            </DashboardGridPanel>}

What am I doing wrong?


Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>