Skip to content

EntityComboBox fires value change event with fromClient=false when value is set from client #5392

Description

@KremnevDmitry

Description

Maybe other components affected too.

EntityComboBox fires a value change event with fromClient = false when its value is set through a user-driven flow, instead of fromClient = true.

This affects every path that sets the value "as if from the client", e.g.:

  • selecting an item in a lookup window and confirming it (LookupSelectAction);
  • clearing the value via EntityClearAction / ValueClearAction.

Application code that relies on HasValue.ValueChangeEvent#isFromClient() to distinguish user input from programmatic changes behaves incorrectly for these fields.

Steps to reproduce

  1. Open a view with an EntityComboBox bound to data and configured with an EntityLookupAction.
  2. Add a value change listener to the field that logs event.isFromClient().
  3. Click the lookup action, select an item in the lookup window, and confirm with the Select button (LookupSelectAction).
    (Alternatively, call entityComboBox.setValueFromClient(entity) directly.)
  4. Observe the value change event reported to the listener.

Actual behavior

A single value change event is fired with isFromClient() == false.

Expected behavior

A single value change event is fired with isFromClient() == true, because the value originates from a user action (as in 2.7.x).


Root cause (verified)

Introduced in 2.8 by the fix for #5164, which added setPresentationValue(value) before setModelValue(value, true) in EntityComboBox#setValueFromClient (the same change was applied to ComboBoxPicker, JmixMultiSelectComboBoxPicker).

Calling setPresentationValue(value) directly writes the Vaadin element value property; the server-side property write synchronously triggers AbstractSinglePropertyField's sync listener with userOriginated = falsesetModelValue(value, false), firing the value change event with fromClient = false. The following setModelValue(value, true) is then a no-op because the model value already equals value. (The presentationUpdateInProgress guard in AbstractFieldSupport is not raised, because it only applies inside AbstractFieldSupport.applyValue(), not on a direct setPresentationValue call.)

In 2.7.x setValueFromClient called only setModelValue(value, true), so the event was fired with the correct flag before the element property was written.

Metadata

Metadata

Assignees

Type

No fields configured for Bug.

Projects

Status
Next

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions