Upgrade to 4.0 Issues and Questions
See original GitHub issueI set up a new branch from master on my app that was using the previous version of this framework then to upgrade to 4.0. Previous version worked fine. I upgraded, your “breaking changes” notes were quite small, thus felt like easy upgrade.
Note: The v4 I can see is faster to load…sweet!
Here are my issues: Note: I have tried various things because I am a good programmer and I see the source, but I just get errors, and just do not understand the issue from working in v 3 and fail in v 4.
<div data-is-scrollable="true" style="height:400px;overflow-y:auto;">
<BFUDetailsList ItemsSource="UserRoleListItems" TItem="RoleBasedAccessModel"
IsHeaderVisible="true"
Columns="Columns"
GetKey=@(x=>x.Id)
LayoutMode="DetailsListLayoutMode.Justified"
SelectionMode=@SelectionMode.Single
Selection="selectedItem"
SelectionChanged="SetSelectedUser" /> <-- this worked before now gone (SelectionChanged)
</div>
BFUDetailsList SelectionChange is gone <- how do I set my selected item in the list event. I tried all kinds of crazy events, funcs, lambdas I just could not figure this out. But why change?
I changed to BFUDetailsListAuto which does have the SelectionChanged and I get error
<div data-is-scrollable="true" style="height:400px;overflow-y:auto;">
<BFUDetailsListAuto ItemsSource="UserRoleListItems" TItem="RoleBasedAccessModel"
IsHeaderVisible="true"
Columns="Columns"
GetKey=@(x=>x.Id)
LayoutMode="DetailsListLayoutMode.Justified"
SelectionMode=@SelectionMode.Single
Selection="selectedItem"
SelectionChanged="SetSelectedUser"/>
</div>
crit: Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100]
Unhandled exception rendering component: Value cannot be null. (Parameter ‘second’)
System.ArgumentNullException: Value cannot be null. (Parameter ‘second’)
at System.Reactive.Linq.Observable.Merge[PropertyChangedEventArgs](IObservable1 first, IObservable
1 second) in //Rx.NET/Source/src/System.Reactive/Linq/Observable.Multiple.cs:line 572
at BlazorFluentUI.BFUDetailsListAuto1.<>c[[UnifiedIntakeTool.Shared.Models.RoleBasedAccessModel, UnifiedIntakeTool.Shared, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].<CreateSourceCache>b__134_17(IObservable
1 x, BFUDetailsRowColumn1 y) at System.Linq.Enumerable.Aggregate[BFUDetailsRowColumn
1,IObservable1](IEnumerable
1 source, IObservable1 seed, Func
3 func)
at BlazorFluentUI.BFUDetailsListAuto1[[UnifiedIntakeTool.Shared.Models.RoleBasedAccessModel, UnifiedIntakeTool.Shared, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]].<CreateSourceCache>b__134_4(PropertyChangedEventArgs prop) at System.Reactive.Linq.ObservableImpl.SelectMany
2.ObservableSelector.[[System.ComponentModel.PropertyChangedEventArgs, System.ObjectModel, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a],[System.ComponentModel.PropertyChangedEventArgs, System.ObjectModel, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a]].OnNext(PropertyChangedEventArgs value) in /_/Rx.NET/Source/src/System.Reactive/Linq/Observable/SelectMany.cs:line 869
then in the same page, I get a new error with the checkbox: <- working in v 3
This is my code from v 3 working fine within a EditForm to manage user RBAC in an admin page.
<EditForm id="addUserForm" Model="@userData" OnSubmit="@AdduserDataAsync">
<div>
<BFUTextField Label="User Fullname:"
Disabled="@(userData.Id != Guid.Empty)"
Required="true"
@bind-Value="@userData.UserFullName" @bind-Value:event="OnInput" />
</div>
<div>
<BFUTextField Label="User Email:"
Disabled="@(userData.Id != Guid.Empty)"
Required="true"
@bind-Value="@userData.UserEmail" @bind-Value:event="OnInput" />
</div>
<div className="ow-role-inputs">
<BFUCheckbox Label="Owner"
Checked="@userData.Roles.Where(x => x.RoleName.Equals("Owner")).Any()"
CheckedChanged="@(eventArgs => { RoleChange("Owner", eventArgs); })" />
<BFUCheckbox Label="Administrator"
Checked="@userData.Roles.Where(x => x.RoleName.Equals("Administrator")).Any()"
CheckedChanged="@(eventArgs => { RoleChange("Administrator", eventArgs); })" />
<BFUCheckbox Label="User"
Checked="@userData.Roles.Where(x => x.RoleName.Equals("User")).Any()"
CheckedChanged="@(eventArgs => { RoleChange("User", eventArgs); })" />
<BFUCheckbox Label="ReadOnly"
Checked="@userData.Roles.Where(x => x.RoleName.Equals("ReadOnly")).Any()"
CheckedChanged="@(eventArgs => { RoleChange("ReadOnly", eventArgs); })" />
</div>
</EditForm>
your framework code:
protected override Task OnParametersSetAsync()
{
if (CascadedEditContext != null)
{
if (CheckedExpression == null)
{
**throw new InvalidOperationException($"{GetType()} requires a value for the 'CheckedExpression' " +
$"parameter. Normally this is provided automatically when using 'bind-Checked'.");**
}
FieldIdentifier = FieldIdentifier.Create<bool>(CheckedExpression);
CascadedEditContext?.NotifyFieldChanged(FieldIdentifier);
CascadedEditContext.OnValidationStateChanged += CascadedEditContext_OnValidationStateChanged;
}
I am not good at looking and GIT diffs, but what changed here? how do I fix this? I moved the checkbox out of the EditForm elements to fix issue. <- why?
Finally, This one is really stumping me… v3 DataList render fine v 4, I get some extra “}” that throws my styling off. Same code as v3, but v4 get extra “}” in my list <- again, possibly something on my end, but very strange
So, I am questioning why the v3 working fine, I just upgrade Nuget to v4 and my app fails with DataList issues and Checkbox as a child of an EditForm issue, and some rando ‘}’ in my DataLists.
Finally, I would like to help out on this repo once I get caught up and understand a bit more.
Cheers!
Issue Analytics
- State:
- Created 3 years ago
- Comments:6
Top GitHub Comments
OK! I just merged a bunch of PRs (thanks Nino) and added some fixes of my own and setup a new nuget package build. Since this is badly breaking change, I’m just going to put it out there and hope there are no further big bugs.
In addition to the two methods for setting selected items above, I’ve added a new method that should be easier:
The
Selection.SelectedItems
property is what you want to use to set which items are selected programmatically. You can still use the methods if you have keys or index numbers, but the actual items work, too. You still need to set theGetKey
callback first, because it needs that to find the key for each item you’re adding.@bind-Selection
no longer works on ANY list. It was a leftover from v3 I forgot to remove. I also removed it from the demo since it would break things.@NPadrutt @limefrogyank
OK. with regards to the “}” we can close this issue thread as the bug was fixed with a PR.
I have solved for everything else this morning.
I just wanted to select an item in the DataList and update my UI with that data I selected on a Single select Selection mode. Solved: Yes, thanx to the comments seeing the Selection object is the way to go. I wired up the event ->
SelectedItem.OnSelectionChanged += new EventHandler(SetSelectedUser);
The other wonky error Value cannot be null. (Parameter ‘second’) System.ArgumentNullException: Value cannot be null. (Parameter ‘second’) Was due to when I switched to BFUDetailsListAuto the BFUDetailsRowColumn needed the fieldSelector type set (at least this solved the error)
Thanx