Skip to content

Conversation

@MarvinKlein1508
Copy link
Collaborator

Pull Request

📖 Description

This PR introduces a new parameter OptionComparer to ListComponentBase which can be used to check an item before it's being added to a FluentAutocomplete component. This makes it much easier to use this component when you are fetching new object instances from external APIs or from a database without Entity Framework.

Demo and Unit-test have also been added.

Example:
autocomplete_comparer_example

🎫 Issues

Fix #3881

✅ Checklist

General

  • I have added tests for my changes.
  • I have tested my changes.
  • I have updated the project documentation to reflect my changes.
  • I have read the CONTRIBUTING documentation and followed the standards for this project.

Component-specific

  • I have added a new component
  • I have added Unit Tests for my new component
  • I have modified an existing component
  • I have validated the Unit Tests for an existing component

@vnbaaij
Copy link
Collaborator

vnbaaij commented Jun 5, 2025

I'll try to check and get this in ASAP. Was about to release 4.12 but think we can squize this in.

@MarvinKlein1508
Copy link
Collaborator Author

You won't believe how happy this would make me!

@MarvinKlein1508
Copy link
Collaborator Author

btw. can you tell me how you can merge the master this fast into the branch? In my own projects I always need to pull it in VS and merge it with the git menu.

@MarvinKlein1508
Copy link
Collaborator Author

MarvinKlein1508 commented Jun 5, 2025

@dvoituron would it be a good idea to overwrite OptionComparer in the other lists and mark it there as Obsolete? So no people will try to use it there.

@dvoituron
Copy link
Collaborator

No. If we add a feature, we have to develop it from A-Z. Why should it only be for Autocomplete?

@MarvinKlein1508
Copy link
Collaborator Author

No. If we add a feature, we have to develop it from A-Z. Why should it only be for Autocomplete?

Because all other lists doesn't allow you to fetch different instances. The all have one parameter to provide items. Only FluentAutocomplete allows you to get items with new instances using it's OnSearch parameter.

@MarvinKlein1508
Copy link
Collaborator Author

@dvoituron I have added tests for the other components too. FluentCombobox doesn't support multiple so it doesn't affect this component at all.

The other two components can only be affected when your binded list contains different instances then the provided list via item parameter. This could only happen if you fetch this the list which is bound to from the database and a second list of items which contain all items.

@dvoituron
Copy link
Collaborator

If this parameter is only used with the Autocomplete, why to add this parameter in the ListBase?

You can add this parameter in the Autocomplete and override OnSelectedItemsChangeHandlerAsync. And calling the Base method to avoid to rewrite all.

This is logical to have this parameter only for the Autocomplete.

@MarvinKlein1508
Copy link
Collaborator Author

MarvinKlein1508 commented Jun 5, 2025

@dvoituron forget what I said about only for FluentAutoComplete. Every component which support Multiple is benefitting from this change.

FluentListbox and FluentSelect behaved the same when you did the following:

  1. Load your IEnumerable with assigned items from the database for your specific object
  2. Load all items for these components from the database and provide them via Items parameter

This will also fix this behaviour as well :)

Copy link
Collaborator

@dvoituron dvoituron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Last small changes before to merge

@vnbaaij vnbaaij merged commit d6d5ff9 into microsoft:dev Jun 6, 2025
4 checks passed
@MarvinKlein1508 MarvinKlein1508 deleted the fix-two-instances branch June 6, 2025 09:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: "duplicate" items in FluentAutoComplete

3 participants