-
Notifications
You must be signed in to change notification settings - Fork 25
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
Sort selectedItems #67
Comments
Hi @lipisak, It could be related to the caption generator, but I can't say for certain. The "ordered" example in the demo https://multiselect-combo-box-flow.herokuapp.com seems to be working okay. Any chance you can provide a minimal reproducible project with the issue? Thank you, |
Hi @gatanaso, |
Hi @lipisak and thanks for sharing the file. Unfortunately I can't really run or use that to see how it behaves, as it's missing other internal classes from your project. Are you able to reproduce the issue with the vanilla |
Hi @gatanaso, L. |
Hi @lipisak, Yeah, though the |
Hi @gatanaso this is the most simplified version of the usage I can create :) The MultiComboBoxField must be preserved as it behaves as wrapper Set<->List. https://github.com/lipisak/multiselectcombo-vaadin14-minimalRunnable This project uses only vaadin and your component - no 3rd parties. Thank you |
Oh, I think I've understood the issue wrongly from the beginning 😄 Yes, you are right. If you use set ordered, the selected items will be sorted alphabetically on the client. If you omit it, then the value order is lost due to the internal data representation. |
Guess it doesn't matter in my example if you set ordered true or not (on my wrapper which passes the value to your component). The items are incorrectly set anyway :) If I understand ordered feature correctly - it is used on client side. The server only gets the values from client side, maps it to server representation and returns them in the Set. Which unfortunatelly can be ordered differently - HashSet vs LinkedHashSet :) I don't even know how it's possible that your examples work. |
Just to clarify one more time. Your use case is such that the selected items (tokens/chips) always need to be sorted based on how they appear in the drop-down list, irregardless of the order in which those were selected? For example, if the list of drop-down items is: "Mon, Tue, Wed, Thu, Fri, Sat and Sun". And nothing is selected. You open the drop-down and select: "Wed, Sat and Mon", then the expectation is that the selected items (tokens/chips) will be in the following order: "Mon, Wed and Sat" (they will appear as such in the input field)? If this assumption is correct, unfortunately, this is not currently supported and would need to be implemented separately. |
This is exactly the example I should provide you :-D It would be very helpful for us, if this feature would be possible. |
Hi @gatanaso, |
Thanks, I will have to think about it as well. Not sure what would be the best approach. I am open to suggestions in case you have any :) |
Hi @lipisak, One way you can temporarily work around this limitation, is by overriding the client side sorting:
The above code will ensure that the list of selected items is sorted according to the given Hope this helps, |
Hi,
I use your component as selector of Days of week. In selection dialog it's ok - values are sorted as on input. When I select item these values are not correctly sorted. Guess it's because of Set (not sorted). I am attaching an image where incorrect sorting is visible. setOrdered(BOOLEAN) doesn't take any effect.
I am using version for Vaadin 14 - 2.5.0
Enum is created from English values (MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY) and caption generator is used for translations
The text was updated successfully, but these errors were encountered: