-
-
Notifications
You must be signed in to change notification settings - Fork 386
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
MatChip / MatChipSet: implemented exclusive and non-exclusive selection #601
Conversation
…lti-selection (Filter), two-way-bindable
… and removed auto-remove logic. the remove logic was a nice idea but it results in a conflict in DOM management between Blazor and JS which manifests itself in seemingly multiple chips being removed at once when clicking only one.
…sive selection #601 (Thanks to [henon](https://github.com/henon))
Thank you for this contribution. That's great |
I've seen the demo and it working in the documentation site, but am struggling to replicate the Choice Chipset functionality
|
@markiemarkus have you looked at the complete source code of the chip demo? I guess you are missing a variable declaration or so. |
I had thought so, I have the code segment as
|
I just verified that it works. Follow these steps:
|
Hey, were you able to solve your problem? I have exactly the same issue. |
@GitSheva are you using the preview build BatBlazor 2.6.1-develop-013 ? |
@henon @markiemarkus the issue was resolved updating the package with 2.6.1. Thanks for your help. |
@henon @markiemarkus another question, do you know how to make the first MatChip selected by default (only with the first load)? I used IsSelected property, it's loading control with fist chip selected but I can't change it anymore. Do you have any example? Thanks |
I know that problem but I'm not sure it can be solved without changing something in the MatChip/MatChipSet code. Have you tried assigning the reference of the first chip to the variable selectedChip? |
@henon it worked, thank you so much... |
@henon maybe you know as well how to pre-select one of the choice chips by the value from code? |
I don't know off the top of my head. Either that or set SelectedChips on ChipSet via two-way binding to the Chips you want to be selected. |
@henon, not sure if I'm begging for help in the right place here, but I'm using the Filter setting to select a combination of on/off MatChips. I need to preselect multiple chips on page initialisation, and track changes to enabled chips so that I can update the database on changes. |
I think this is a bug that needs to be fixed in MatChipSet implementation. |
There is a bug indeed regarding preselection, I added some chips to my app and found out what the issue is. Currently I have implemented a workaround in my app but will submit a correction PR when I have time for it. |
Or I could give someone pointers if they want to fix it. (Not at the computer atm thats why I talk in riddles) |
Thanks, line 75 of BaseMatChipSet.cs looks dodgy to me - I don't see how you can ever preselect anything using set_SelectedChips?
No worries, I'll hang on for your fix, thanks. |
Yup, replacing MatChipSet.cs,line 75 with matching on the Label value instead of a MatChip hash allows preselecting to work in OnAfterRender:- var selected = new HashSet(value.Select(x => x.Label)); Issue #671 raised. |
I have a problem with MatChipSet/MatChip and IsSelected. If I put any value there then when I click a chip selection does not change. This seems like it should work? Or I'm using it wrong? I guess I could do what @peterthomastlc have suggested but I would like to use the IsSelected property, otherwise what is it for? @lindespang did you have some kind of solution/hint to give for this problem? EditNow I understand why the Will try my hand on a solution tomorrow and create a PR |
According to Material Design Components: there are Choice and Filter chips.
Choice: exclusive selection (visualized by color change)
Filter: non-exclusive selection (visualized by check-marks)
Choice+Filter: exclusive selection with the ability to unselect currently selected value.
I implemented this behavior in MatChipSet which are turned on by setting the Parameter flags Choice=true or Filter=true.
MatChipSet exposes SelectedChip and SelectedChips which can be bound two-way.
Also, Chips can be configured to be removable by click on the TrailingIcon or not if IsRemovable=false. MatChipSet exposes an event that is raised for every removed chip.
This feature was requested by issue 181
This is my first full-fledged MatBlazor component and I'll apreciate any comments or tips for improvement.
I am thinking about implementing a nice little demo that shows off the new features (adding and removing chips, binding selection, etc) for our docs.