ui5-webcomponents icon indicating copy to clipboard operation
ui5-webcomponents copied to clipboard

ComboBox: Change Event does not provide Item

Open MFel0123 opened this issue 1 year ago • 1 comments

Bug Description

The UI5 ComboBox of UI5 Web Components does not offer the selected Item for the event handling when the event is fired, only the pure text seems to be offered to find the item. The text is not sufficient to really identify the item (as a key like information). There could be two items with the same text.

Expected Behavior

It seems that currently only the selection change event has the selected item. Why is it missing for the change event? Do we have to use both events at the same time?

If I am wrong and we have the option to get the selected item directly at the change event - the please tell me how and accept my apologies.

Steps to Reproduce

  1. Look at the documentation: https://sap.github.io/ui5-webcomponents/playground/components/ComboBox/
  2. find the section for the events: only for the selection-change event the item is documented as a property

Context

  • UI5 Web Components version: {...}
  • OS/Platform: {...}
  • Browser: {...}
  • Affected component: {...}

Log Output / Stack Trace / Screenshots

{...}

Priority

  • [ ] Low
  • [x] Medium
  • [ ] High
  • [ ] Very High

The priority indicates the severity of the issue. To set the appropriate priority consider the following criteria:

  • Breaks entire application or system - High or Very High
  • Accessibility issue - Medium or High
  • Functional issue - Medium or High
  • Visual issue - Low or Medium

Note: The priority might be re-evaluated by the issue processor.

Stakeholder Info (if applicable)

  • Organization: {...}
  • Business impact: {...}

MFel0123 avatar Aug 11 '22 07:08 MFel0123

Hello,

Returning to the queue since the dispatching process was not followed and the issue was directly put on our component without pre-analysis.

Elena

elenastoyanovaa avatar Aug 15 '22 13:08 elenastoyanovaa

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

The change event is triggered from the input field and contains information for what is typed inside from the user. The typed from the user text could be something irrelevant to the ui5-combobox popover list items or it could be a text referring to more than one list item. If we type "Cuba" into the input field and there are more than one list items in the popover with the same text, then all of them will be highlighted. This is not the case though with openui5 combobox control. There in the same scenario only the first appearance of "Cuba" in the list will be highlighted.

For me the question is how the combobox would use the typed in the input value to render its list of items in the popover. Don't think there should be an additional key property given via the change event object, in order to relate the typed input via an list item. This would be a component internal logic.

This scenario could easily be tested via the dev samples.

Best Regards, Boyan

unazko avatar Aug 20 '22 10:08 unazko

Hey @MFel0123

We believe that the value is the key property to be used to get the valuable information from the ComboBox. In case you really want to get the selected item and implement different behaviour when item is pressed or value is typed, you can do something like: https://jsbin.com/qafuciroza/1/edit?html,console,output

Change event is kind of borrowed from the Input's change event and enhanced to be fired when item is pressed as well.

Please give us you feedback if the solution above works for you.

Regards, Martin

MapTo0 avatar Aug 25 '22 22:08 MapTo0

Hi Martin, yes, thank you very much, that is the solution that we already use currently as a preliminary solution to identify the item when using the change event: We simply store the selected item before the change event is fired (as you do it in your example).

This will work if we always have a selected item when we need it (so the selection change event should be fired before the change event when an item can be identified).

So will you support this procedure also in future?

Best Regards Matthias

MFel0123 avatar Aug 26 '22 07:08 MFel0123

I would suggest to you take a look at that discussion and a feature request here: https://github.com/SAP/ui5-webcomponents/issues/1447

Once we got a proposal for a solution we will post there.

Both requests seem to be quite similar.

Duplicate of: https://github.com/SAP/ui5-webcomponents/issues/1447

Regards, Martin

MapTo0 avatar Aug 26 '22 13:08 MapTo0