-
Notifications
You must be signed in to change notification settings - Fork 176
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Synchronized property unexpectedly reverts to last synchronized state #20365
Comments
Here is a better example. I can reproduce the bug using a TextField on a slow internet connection: TextField textField = new TextField();
add(textField);
Screen.Recording.2024-11-04.at.14.26.58.movHowever, if I follow Backspace with Enter while the previous round-trip is going on, another round-trip is scheduled, which applies the backspace correctly. |
The client-side property binding in Flow works in this way. The server round-trip is done asynchronously, and once it's done, flow client does a flush to make sure all the bound properties match the values that were sent to the server. It has been this way for years and I'm pretty sure I've seen that slow network example in something like Vaadin 6/7/8 (provided that network is slow enough or user is fast enough to type). I don't think we can change the basic functionality without breaking a lot of things in the process. So I'd say we need to provide some kind of workaround for the use case needed here. I have a clarifying question though, in the first example of
what should happen? The dispatched event triggers a server round-trip. Should the value change on the next line trigger another server round-trip right after the first one has finished? Or should it not trigger a server round-trip, leading to missynchronized values between server and client? Or some other option I did not think of? |
It should not trigger an immediate round-trip and rather keep the new value until the next |
Alright, so that means we would need to remove the whole synced property flush process that is done after the server round-trip finishes. I can try that and see what all breaks. Pinging @Legioth as well as he might have some better ideas here as well |
@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 Edit: some shortcut key test is failing but everything else is passing |
The second showcase gives a better presentation of the issues. It's looks now end-user affecting especially with the slow internet. I'm leaning towards this is the bug in Flow, no matter what the solution would be. As a end-user, I don't want my new value of the component to be overridden by the previous one. |
This 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? |
Unfortunately, I don't see any changes with your branch. I tested both DatePicker and TextField.
I would expect it to override. |
Thanks @vursen, I'll keep working on a fix. Is it enough to test with vaadin/flow-components#6743 or do I need a custom version of web-components as well? |
Thank you. Yes, that's enough. This feature affects only the Flow component. Here is the test that reproduces the issue: |
Yes, I think so. |
Re-pinging @Legioth in case he has any fresh ideas. My current problem is that when the value is changed during round-trip but before flush, we do not get any kind of event about that to flow-client. Due to that I could not figure out a way to detect if the value was changed by the user (and should not be recomputed) or if it is invalid/stale for some other reason (and should be recomputed). Could not find anything in client side binding or flush/post-flush listeners to help with this either. |
I don't remember what the implementation does but one potential approach might be to keep a timestamp for when a synchronized value was last sent to the server and when an updated value was last received from the server. We should re-apply only if the received value is newer than the sent value. Might actually be overkill to have a timestamp. Could just as well have a boolean to track whichever has happened most recently. |
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 overwrites user's changes once the round-trip finishes. Instead, user's changes are preserved. However, if the server-side value change handling logic actually changes the value and returns the new value to the client, that value will override any user input during round-trip. Fixes #20365
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 overwrites user's changes once the round-trip finishes. Instead, user's changes are preserved. However, if the server-side value change handling logic actually changes the value and returns the new value to the client, that value will override any user input during round-trip. Fixes #20365
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 overwrites user's changes once the round-trip finishes. Instead, user's changes are preserved. However, if the server-side value change handling logic actually changes the value and returns the new value to the client, that value will override any user input during round-trip. Fixes #20365 Co-authored-by: Teppo Kurki <[email protected]>
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 overwrites user's changes once the round-trip finishes. Instead, user's changes are preserved. However, if the server-side value change handling logic actually changes the value and returns the new value to the client, that value will override any user input during round-trip. Fixes #20365 Co-authored-by: Teppo Kurki <[email protected]>
This ticket/PR has been released with Vaadin 24.6.0.alpha3 and is also targeting the upcoming stable 24.6.0 version. |
This ticket/PR has been released with Vaadin 24.4.17. |
This ticket/PR has been released with Vaadin 24.5.5. |
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.
Screen.Recording.2024-10-28.at.18.12.51.mov
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
Versions
The text was updated successfully, but these errors were encountered: