preline icon indicating copy to clipboard operation
preline copied to clipboard

ComboBox options are always sorted alphabethically

Open antero111 opened this issue 7 months ago • 0 comments

My Select component generally uses the ComboBox plugin for its well working search ability. My latest select would have included options for following data types: types = ['race', 'practice', 'test', 'other'] which must be kept in that order.

In Preline the select options are sorted alphabethically as seen here, which don't really work for my use case. I wan't to emphasize the importance of the possible options with custom order.

Image

In other cases (such as the country selection example) its completely fine to have alpha sorting and in its own ways, helps for better UX.

Here is the sort functionality in your plugin:

https://github.com/htmlstreamofficial/preline/blob/069c8213737b3c9c675b18b5994ac01caa7528d4/src/plugins/combobox/index.ts#L403-L418

Would an optional attribute for disabling the sorting be considered as an addition?

Currently I "hack" the sorting by adding an index to the beginning of the option text and then hide it with way too complicated tricks but unfortunately the latest v3.1.0 broke this kind of behaviour.

antero111 avatar Jun 23 '25 13:06 antero111