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

Revert "fix: make property change listener trigger on removeProperty (#19196)" #19310

Merged
merged 2 commits into from
May 6, 2024

Conversation

mshabarov
Copy link
Contributor

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.

Copy link

sonarcloud bot commented May 6, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

Copy link

github-actions bot commented May 6, 2024

Test Results

1 101 files  ± 0  1 101 suites  ±0   1h 27m 35s ⏱️ + 4m 45s
7 004 tests  -  9  6 955 ✅  -  9  49 💤 ±0  0 ❌ ±0 
7 346 runs   - 41  7 287 ✅  - 39  59 💤  - 2  0 ❌ ±0 

Results for commit 04de150. ± Comparison against base commit 4769d87.

This pull request removes 9 tests.
com.vaadin.flow.component.AbstractSinglePropertyFieldTest ‑ stringNullFieldWithDefaultEmpty_basicCases
com.vaadin.flow.component.PropertyDescriptorsTest ‑ booleanPropertyDefaultFalse_resetToDefault_propertyChangeListenerTriggered
com.vaadin.flow.component.PropertyDescriptorsTest ‑ booleanPropertyDefaultTrue_resetToDefault_propertyChangeListenerTriggered
com.vaadin.flow.component.PropertyDescriptorsTest ‑ doublePropertyDefaultOne_resetToDefault_propertyChangeListenerTriggered
com.vaadin.flow.component.PropertyDescriptorsTest ‑ doublePropertyDefaultZero_resetToDefault_propertyChangeListenerTriggered
com.vaadin.flow.component.PropertyDescriptorsTest ‑ integerPropertyDefaultOne_resetToDefault_propertyChangeListenerTriggered
com.vaadin.flow.component.PropertyDescriptorsTest ‑ integerPropertyDefaultZero_resetToDefault_propertyChangeListenerTriggered
com.vaadin.flow.component.PropertyDescriptorsTest ‑ stringPropertyDefaultEmpty_resetToDefault_propertyChangeListenerTriggered
com.vaadin.flow.component.PropertyDescriptorsTest ‑ stringPropertyDefaultFoo_resetToDefault_propertyChangeListenerTriggered

@mshabarov mshabarov merged commit 942b667 into main May 6, 2024
26 checks passed
@mshabarov mshabarov deleted the revert-property-change-listener branch May 6, 2024 12:43
vaadin-bot pushed a commit that referenced this pull request May 6, 2024
…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.
vaadin-bot added a commit that referenced this pull request May 6, 2024
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants