Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TransferList binding to Items #5631

Open
blenke opened this issue Jul 22, 2024 · 3 comments
Open

TransferList binding to Items #5631

blenke opened this issue Jul 22, 2024 · 3 comments
Assignees
Labels
Type: Bug 🐞 Something isn't working
Projects

Comments

@blenke
Copy link

blenke commented Jul 22, 2024

Blazorise Version

1.5.3

What Blazorise provider are you running on?

Bootstrap 5

Link to minimal reproduction or a simple code snippet

Not sure if this a bug or a feature, but if I fill the Items and only want to know the items that appear in the listEnd (or listStart) and thus do not include a bind to one of these then the Items list will be changed by the TransferList component. Following the web site example you can see the behaviour:

<TransferList TItem="string"
              Items="@list"
              SelectionMode="ListGroupSelectionMode.Single"
              Mode="ListGroupMode.Selectable"
              Scrollable=false
              ShowMoveAll=false
             
              @bind-ItemsEnd=@listEnd
              ValueField="item => item"
              TextField="item => item">
</TransferList>

<br />
<b>list:</b>
@foreach (string s in list)
{
    @(s + ",")
}


@code {
    private List<string> list = new List<string> { "Apple", "Banana", "Cherry", "Grapes", "Orange", "Pear", "Strawberry" };
    
    private List<string> listEnd;
}

Steps to reproduce

Move items from start to end and observe that the input Items list is changed

What is expected?

The Items list should not be changed, the result should be in ItemsStart and ItemsEnd only

What is actually happening?

Items moved to ItemsEnd are removed from Items. It is problematic because I used this in a modal and want the user to be able to OK/Cancel the selection. If they Cancel then the Items have changed. Its odd that the Items are changed especially when no @bind-Items is defined.

What browsers do you see the problem on?

No response

Any additional comments?

No response

@blenke blenke added the Type: Bug 🐞 Something isn't working label Jul 22, 2024
@David-Moreira
Copy link
Contributor

Hello @blenke If I understand correctly your complaint is that Items="@list" gets mutated, correct?

For a quick workaround I recommend just copying a new list and allocating it to Items="@copyList".

We'll take a look at why the collection is being mutated in that way and if it's intended or not. On first look it seems like it is not an intended behavior.

@David-Moreira David-Moreira added this to 🔙 Backlog in Support via automation Jul 22, 2024
@David-Moreira David-Moreira self-assigned this Jul 22, 2024
@blenke
Copy link
Author

blenke commented Jul 22, 2024

Indeed it gets mutated. I just added the ItemsStart but not use it and the problem was resolved but it took me some time to figure out what was wrong. If it is intended behavior then i would suggest to update the documentation.

@David-Moreira
Copy link
Contributor

Thanks for your help. We'll let you know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug 🐞 Something isn't working
Projects
Support
  
🔙 Backlog
Development

No branches or pull requests

2 participants