Skip to content

UI5 mdc field does not properly update ValueHelp reference after calling setValueHelp #28

@MarvinWeitz

Description

@MarvinWeitz

Hi everyone, the SAP customer service at me.sap.com told me open an issue in this tutorial repo regarding an issue I identified with mdc. I'll copy paste the ticket message below:

When using a sap.ui.mdc.Field and assigning it a value help with typeahead (for example, as shown in the sample project https://github.com/SAP-samples/ui5-mdc-json-tutorial), I am seeing unexpected behavior after changing the value help and then triggering the typeahead popover.

Specifically, when the field is initially assigned a value help with the ID initialVH and later field.setValueHelp("newVH") is called, the typeahead popover still uses the value help initialVH. This issue only affects the typeahead popover. When opening the value help dialog via the icon in the MDC field, the new value help (newVH) is correctly used.

I have identified a likely cause in the SAPUI5 source code. In sap/ui/mdc/field/FieldBase-dbg.js, inside the _handleContentLiveChange method, there is a check:

if (!this._fnLiveChangeTimer)

When this condition is met, this._fnLiveChangeTimer is created and stored as a callback function. This callback contains the logic that handles the typeahead behavior.

When the value help of the field is changed, this._fnLiveChangeTimer is not reset. As a result, the existing callback is reused and still holds references to the old value help (initialVH). If you debug this in Chrome DevTools, you can see that outside of the callback, this.getValueHelp() correctly returns newVH. However, inside the callback, for example in:

oValueHelp.isTypeaheadSupported().then((bTypeahead) => { return !!bTypeahead && _handleTypeahead(); });

the variable oValueHelp still refers to initialVH.

This suggests that this._fnLiveChangeTimer should be reset when the value help association of the field changes, so that the typeahead logic uses the updated value help reference.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions