Skip to content
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

Binder: Improve change detection #19260

Open
onuridrisoglu opened this issue Apr 25, 2024 · 0 comments
Open

Binder: Improve change detection #19260

onuridrisoglu opened this issue Apr 25, 2024 · 0 comments

Comments

@onuridrisoglu
Copy link

Describe your motivation

Currently, when the value of a bound field changes, the binding is considered as "changed" and is included in the changedBindings, regardless of whether the user reverts to the initial value. For example, if the value of a name field is changed from "foo" to "foo bar" and then reverted to "foo", the binding still appears in changedBindings, causing binder.hasChanges() to return true.

It's a common use case to enable the save button only if there is any changes in the form. This way it would be possible to enable the save button only if there are "real" changes.

Describe the solution you'd like

A potential solution is to store the initial value of each binding when the readBean method is invoked. Subsequently, after each value change, this initial value can be compared to the new value. If the new value matches the initial one, the binding would not be marked as "changed," thereby ensuring that changedBindings only includes entries where the current value differs from the initial value.

Describe alternatives you've considered

An alternative solution could involve extending this mechanism to maintain a list of all changes, which would facilitate an "undo" feature. By tracking each change as an entry in a history list, users can easily revert the most recent modifications or even all changes back to the original state.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: 🪵Product backlog
Development

No branches or pull requests

2 participants