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.47k stars 254 forks source link

[Select, (Multi)ComboBox]: support key-value props #7777

Open ilhan007 opened 8 months ago

ilhan007 commented 8 months ago

Feature Request Description

Select web component already has this key-value props available - the Option has "value" (which is like key, it's not displayed) and text content (which is the displayed "value" in key-value terms).

The ComBoxItem and the MultiComboBoxItem don't provide a pair of props, they both have "text" (which is the displayed "value" in key-value terms), but don't have "key" or equivalent.

The main use-case that the author provided is a list of countries and their codes and the codes he would like to set as keys that are not displayed, but later get. Alternative that could be done is to maintain this mapping in the app code, which he finds somewhat inconvenient.

Proposed Solution

Add support for "key", "value" ("text" already plays as "value", so "key" is the missing piece).

Proposed Alternatives

Alternative that could be done is to maintain this mapping in the app code, which he finds somewhat inconvenient.

Organization

SAP Build Process Automation

Additional Context

No response

Priority

None

Privacy Policy

timogeib commented 8 months ago

There is not way to define a key, which is hidden and a value to display (translated) Selected option should always set the value of the key to the FormControl. See simple html select https://www.w3schools.com/tags/att_option_value.asp

"value" is the key "innerHtml" is the translatable value to display Issue 91 for example Most of the no FormControl issues are related to "touched" not updated. -> We only set Error state to inputs AFTER they are touched to prevent the whole form being red without touching anything. So we need to call markAsTouched on the FormControl after a change manually

ilhan007 commented 7 months ago

Select web component already has this key-value props available - the Option has "value" (which is like key, it's not displayed) and text content (which is the displayed "value" in key-value terms).

It's true the ComBoxItem and the MultiComboBoxItem don't provide a pair of props, they both have "text" (which is the displayed "value" in key-value terms), but don't have "key" or equivalent.

The main use-case that the author provided is a list of countries and their codes and the codes he would like to set as keys that are not displayed, but later get. Alternative that could be done is to maintain this mapping in the app code, which he finds somewhat inconvenient.

@timogeib feel free to add more to that

ilhan007 commented 7 months ago

Hello @SAP/ui5-webcomponents-topic-rl this feature request belongs to your ownership.

hristop commented 6 months ago

Internal BLI was created: BGSOFUIRILA-3771