-
Notifications
You must be signed in to change notification settings - Fork 164
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
fix: make property change listener trigger on removeProperty #19196
Conversation
55f096a
to
c5eb084
Compare
c7cb2ff
to
01f794d
Compare
@akhodyko thanks for you contribution! Looks good to me! May I transfer this pull request to "ready for review" state? |
yes, you can, but there are some trouble with |
That seems wrong, if the Binder doesn't throw while the exception happens in the converter. Weird side effect. We will take a look, thanks! |
138983e
to
c7f5c9d
Compare
I think I will try to explain:
According to that, because of we have in that test Replacing bean Person to another with non null firstName field fixed the test. |
2ef3919
to
e826351
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As the property removal is now considered as non-client originated event, we have to change to Assert.assertFalse(event.get().isUserOriginated());
in ElementPropertyMapTest::removeProperty_fireEvent_listenerIsNotNotified
This makes sense, okay. |
Requested another review from @caalador , just in case, if I missed something important, the overall fix looks good to me and correct. |
fb694fb
to
4c41f4f
Compare
done |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
@akhodyko could you please run |
5f86d1a
to
cfb48e3
Compare
done |
Quality Gate passedIssues Measures |
Hi @akhodyko and @mshabarov, when i performed cherry-pick to this commit to 24.3, i have encountered the following issue. Can you take a look and pick it manually? |
…19196)" (#19310) This reverts commit 63e6dfd. The original fix for the property change event is correct per se, but, unfortunately, we faced an odd side effect in the RadioButtonGroup component that blocks our development process and would be a breaking change for RadioButtonGroup's users. Here are some details: The getValue() method of the RadioButtonGroup (and probably other similar components, like Select and CheckboxGroup) returned an item that was set in setValue() before, even if it was an invalid item, e.g. it's key/id wasn't in the list of items for this component. With this change, the PropertyChangeEvent is triggered, that causes handlePropertyChange and hasValidValue method to be called. hasValidValue doesn't properly check if the item is in the list of items on the server and returns true, that causes a state change in setModelValue, that eventually resets the value to null. In other words, if one wants to set a new value, which isn't present in the item's list, the component set the value to null, which sounds like even a bigger bug. The proper behaviour, in my opinion, should be to not accept invalid values and make hasValidValue implementation properly check if the item is present or not, but this turns into more complicated work that may even have a breaking changes in behaviour.
…19196)" (#19310) This reverts commit 63e6dfd. The original fix for the property change event is correct per se, but, unfortunately, we faced an odd side effect in the RadioButtonGroup component that blocks our development process and would be a breaking change for RadioButtonGroup's users. Here are some details: The getValue() method of the RadioButtonGroup (and probably other similar components, like Select and CheckboxGroup) returned an item that was set in setValue() before, even if it was an invalid item, e.g. it's key/id wasn't in the list of items for this component. With this change, the PropertyChangeEvent is triggered, that causes handlePropertyChange and hasValidValue method to be called. hasValidValue doesn't properly check if the item is in the list of items on the server and returns true, that causes a state change in setModelValue, that eventually resets the value to null. In other words, if one wants to set a new value, which isn't present in the item's list, the component set the value to null, which sounds like even a bigger bug. The proper behaviour, in my opinion, should be to not accept invalid values and make hasValidValue implementation properly check if the item is present or not, but this turns into more complicated work that may even have a breaking changes in behaviour.
This has been reverted due to a regression in Vaadin Flow components (to be more precise, in For the record, the failed test is this:
I.e. the component reset the value to |
…19196)" (#19310) (#19311) This reverts commit 63e6dfd. The original fix for the property change event is correct per se, but, unfortunately, we faced an odd side effect in the RadioButtonGroup component that blocks our development process and would be a breaking change for RadioButtonGroup's users. Here are some details: The getValue() method of the RadioButtonGroup (and probably other similar components, like Select and CheckboxGroup) returned an item that was set in setValue() before, even if it was an invalid item, e.g. it's key/id wasn't in the list of items for this component. With this change, the PropertyChangeEvent is triggered, that causes handlePropertyChange and hasValidValue method to be called. hasValidValue doesn't properly check if the item is in the list of items on the server and returns true, that causes a state change in setModelValue, that eventually resets the value to null. In other words, if one wants to set a new value, which isn't present in the item's list, the component set the value to null, which sounds like even a bigger bug. The proper behaviour, in my opinion, should be to not accept invalid values and make hasValidValue implementation properly check if the item is present or not, but this turns into more complicated work that may even have a breaking changes in behaviour. Co-authored-by: Mikhail Shabarov <61410877+mshabarov@users.noreply.github.com>
This ticket/PR has been released with Vaadin 24.4.0.beta2 and is also targeting the upcoming stable 24.4.0 version. |
This ticket/PR has been released with Vaadin 24.5.0.alpha1 and is also targeting the upcoming stable 24.5.0 version. |
Removing element property by calling
com.vaadin.flow.internal.nodefeature.AbstractPropertyMap#removeProperty
does not trigger property change listener because ofcom.vaadin.flow.internal.nodefeature.ElementPropertyMap#remove
method is skipped due toAbstractPropertyMap#removeProperty
method calls super:Fixes #3994