flow: Synchronized property unexpectedly reverts to last synchronized state
Description of the bug
Flow reverts the property’s value to the last synchronized state if the property changes again while the previous update is scheduled or is still being processed on the server. This behavior has blocked progress on DatePicker fallback parser feature.
https://github.com/user-attachments/assets/7ab2dd8b-6a47-48b5-8fee-8bbd5d0aa859
Expected behavior
I’d expect Flow to keep the new value and wait for the next synchronization event to send it to the server.
Minimal reproducible example
// frontend/my-field/my-field.ts
import { html, LitElement } from 'lit';
import { customElement, query } from 'lit/decorators.js';
@customElement("my-field")
class MyField extends LitElement {
@query('input')
inputElement!: HTMLInputElement;
get inputElementValue() {
return this.inputElement.value;
}
set inputElementValue(value) {
console.warn('set inputElementValue', value);
this.inputElement.value = value;
}
onChange() {
this.dispatchEvent(new CustomEvent('change', { bubbles: true, composed: true }));
this.inputElementValue = 'foobar'; // <------ Change the property right after the synchronization event
}
render() {
return html`<input @change="${this.onChange}" />`
}
}
@Tag("my-field")
@JsModule("my-field/my-field.ts")
public class MyField extends Component {
@Synchronize(property = "inputElementValue", value = { "change" })
public String getInputElementValue() {
return getElement().getProperty("inputElementValue", "");
}
}
@Route("my-field")
public class MyFieldView extends Div {
public MyFieldView() {
MyField myField = new MyField();
add(myField);
}
}
Versions
- Vaadin / Flow version: 24.5 and possibly earlier
- Java version: 17
- OS version: Mac OS
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 16 (13 by maintainers)
Commits related to this issue
- fix: client side value binding logic (#20431) Changes client side value binding logic so that if the user modifies the value during server round-trip, the value earlier sent to the server no longer o... — committed to vaadin/flow by tepi 2 years ago
- fix: client side value binding logic (#20431) Changes client side value binding logic so that if the user modifies the value during server round-trip, the value earlier sent to the server no longer o... — committed to vaadin/flow by tepi 2 years ago
- fix: client side value binding logic (#20431) (#20444) Changes client side value binding logic so that if the user modifies the value during server round-trip, the value earlier sent to the server no... — committed to vaadin/flow by vaadin-bot 2 years ago
- fix: client side value binding logic (#20431) (#20443) Changes client side value binding logic so that if the user modifies the value during server round-trip, the value earlier sent to the server no... — committed to vaadin/flow by vaadin-bot 2 years ago
- fix: client side value binding logic (#20431) Changes client side value binding logic so that if the user modifies the value during server round-trip, the value earlier sent to the server no longer o... — committed to vaadin/flow by tepi 2 years ago
Thank you. Yes, that’s enough. This feature affects only the Flow component. Here is the test that reproduces the issue:
enterParsableValue_enterShortcutValueThis also opens another can of worms since arbitrary business logic can do whatever kind of processing for the input value on server side and send it back in the response. I guess in such case server-sent value should still override whatever was input by the user after the round-trip started?
@vursen Could you try your case(s) using https://github.com/vaadin/flow/tree/fix/flush-logic? Locally tested seems to fix the slow network case and did not break any
flow-clienttests.Edit: some shortcut key test is failing but everything else is passing