SAP / ui5-webcomponents

UI5 Web Components - the enterprise-flavored sugar on top of native APIs! Build SAP Fiori user interfaces with the technology of your choice.
https://sap.github.io/ui5-webcomponents/
Apache License 2.0
1.56k stars 267 forks source link

[Feature Request]: Make group-item in combo box a container #7732

Closed yetian closed 1 year ago

yetian commented 1 year ago

Feature Request Description

In the current documentation of the combo box component, the "Grouping" feature is defined in the following way:

<ui5-combobox placeholder="Grouping of items">
        <ui5-cb-group-item text="A"></ui5-cb-group-item>
        <ui5-cb-item text="Argentina"></ui5-cb-item>
        <ui5-cb-item text="Australia"></ui5-cb-item>    
        <ui5-cb-item text="Austria"></ui5-cb-item>  
        <ui5-cb-group-item text="B"></ui5-cb-group-item>
        <ui5-cb-item text="Bahrain"></ui5-cb-item>
        <ui5-cb-item text="Belgium"></ui5-cb-item>
        <ui5-cb-item text="Brazil"></ui5-cb-item>
        <ui5-cb-group-item text="C"></ui5-cb-group-item>
        <ui5-cb-item text="Canada"></ui5-cb-item>
        <ui5-cb-item text="Chile"></ui5-cb-item>
</ui5-combobox>

However, I couldn't find a way to figure out, without code injection, how I can generate dynamically grouped items, at least in Vue.

Proposed Solution

Instead of the current way of creating grouped items, I propose the following. Semantically and visually, it is also clear which items are in which groups.

<ui5-combobox placeholder="Grouping of items">
        <ui5-cb-group-item text="A">
                <ui5-cb-item text="Argentina"></ui5-cb-item>
                <ui5-cb-item text="Australia"></ui5-cb-item>    
                <ui5-cb-item text="Austria"></ui5-cb-item>  
        </ui5-cb-group-item>

        <ui5-cb-group-item text="B">
                <ui5-cb-item text="Bahrain"></ui5-cb-item>
                <ui5-cb-item text="Belgium"></ui5-cb-item>
                <ui5-cb-item text="Brazil"></ui5-cb-item>
        </ui5-cb-group-item>

        <ui5-cb-group-item text="C">
                <ui5-cb-item text="Canada"></ui5-cb-item>
                <ui5-cb-item text="Chile"></ui5-cb-item>
        </ui5-cb-group-item>    
</ui5-combobox>

In Vue, then I can generate the list dynamically:

<ui5-combobox placeholder="Grouping of items">
        <ui5-cb-group-item v-for="(group, index) in groups" :key="group_index" :text="group.name">
                <ui5-cb-item v-for="(item, item_index) in group" :key="item_index" :text="item.name"></ui5-cb-item>
        </ui5-cb-group-item>  
</ui5-combobox>

Proposed Alternatives

No response

Organization

No response

Additional Context

No response

Priority

Medium

Privacy Policy

yanaminkova commented 1 year ago

Hello @SAP/ui5-webcomponents-topic-rl,

Could you please have a look and consider this feature request regarding grouping of items in ui5-combobox?

Thanks and Kind regards, Yana

niyap commented 1 year ago

Hello @SAP/ui5-webcomponents-topic-rl,

We have to analyse and discuss with designer, whether it is feasible to implement this approach?

Kind Regards, Niya

yetian commented 1 year ago

Thanks @niyap for the comment.

I would recommend this way since it is much clearer semantically and I think it is also how grouping is implemented in general. I found some examples in Vue and Angular:

Except for the modern frameworks, this is how a browser supports: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/optgroup?retiredLocale=de

Best regards Ye

yetian commented 1 year ago

Hi @niyap ,

In addition to the coding part, I also noticed that at least in the documentation, the grouping feature is only available for Combo Box, but not for Select. Could you also ask the designers/developers if it makes sense to have the grouping feature for Select as well?

Thanks and cheers Ye

hristop commented 1 year ago

Hi @yetian ,

After discussion with or architects we have decided that this is good candidate for v2.0 of the web-components (4460) as it is incompatible with the current implementation.

So for now we will have to reject it, but we will surely have this in mind when we plan the changes in 2.0.

Best Regards, Hristo

yetian commented 1 year ago

Thanks @hristop! Look forward to v2.0.