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

fix: disabled items can now be part of a CheckboxGroup's valid value #1903

Merged
merged 10 commits into from
Aug 2, 2021

Conversation

sosa-vaadin
Copy link
Contributor

@sosa-vaadin sosa-vaadin commented Jul 14, 2021

Description

EDIT: the "valid" logic was replaced for one where the values of disabled items are checked to see if they changed. If they did, then it's an invalid change and will be rolled back.

The value of a CheckboxGroup is a Set of all selected (checked) items. Items in a CheckboxGroup can have their enabled state managed with an ItemEnabledProvider. This ItemEnabledProvider is also used to check whether the value itself of the CheckboxGroup is valid. If any selected (checked) item is disabled (when checked against the ItemEnabledProvider), then the CheckboxGroup is said to have an invalid value. This check happens every time the value changes.

If the new value is invalid, it immediately rolls back to its previous value. This explains the problems encountered in the issue this PR is trying to fix. By removing this "valid" value logic, any item, whether enabled or disabled, will not invalid the CheckboxGroup's value. The user will still be unable to select (by clicking or focusing) a disabled checkbox item, but its selection can still be set programmatically. Any combination of selected items should be a valid value for the group, regardless of those items being enabled or disabled.

Fixes #1185

Type of change

  • Bugfix

Checklist

  • I have read the contribution guide: https://vaadin.com/docs-beta/latest/guide/contributing/overview/
  • I have added a description following the guideline.
  • The issue is created in the corresponding repository and I have referenced it.
  • I have added tests to ensure my change is effective and works as intended.
  • New and existing tests are passing locally with my change.
  • I have performed self-review and corrected misspellings.

Copy link
Contributor

@sissbruecker sissbruecker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Preliminary review.

I have some trouble understanding what the previous validation logic was about, and therefore am not sure about it's complete removal. I'm wondering if there is anything left that should still be validated (can't think of anything though)?. Need to clarify that.

However I would suggest to add regression ITs for the scenarios that were discussed in the issue:

  • set item enabled provider to disable checkboxes, verify that a disabled checkbox can be changed programmatically ✅Done
  • preselect value in a checkbox, set item enabled provider to disable some checkboxes, verify that non-disabled checkboxes can still be changed manually / from the browser ✅Done

@sissbruecker
Copy link
Contributor

Added regression tests

sissbruecker
sissbruecker previously approved these changes Jul 29, 2021
@alvarezguille alvarezguille self-requested a review July 29, 2021 14:05
@alvarezguille alvarezguille dismissed sissbruecker’s stale review July 29, 2021 14:06

Some changes were requested in pair review

Copy link
Member

@alvarezguille alvarezguille left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@vaadin-bot
Copy link
Collaborator

SonarQube analysis reported 13 issues

  • CRITICAL 2 critical
  • MAJOR 1 major
  • MINOR 7 minor
  • INFO 3 info

Top 10 issues

  1. CRITICAL CheckboxGroup.java#L178: Make "item" transient or serializable. rule
  2. CRITICAL CheckboxGroup.java#L286: Remove usage of generic wildcard type. rule
  3. MAJOR CheckboxGroup.java#L611: Rename "dataProvider" which hides the field declared at line 83. rule
  4. MINOR CheckboxGroup.java#L112: Remove this use of "setDataProvider"; it is deprecated. rule
  5. MINOR CheckboxGroup.java#L138: Remove this use of "setDataProvider"; it is deprecated. rule
  6. MINOR CheckboxGroup.java#L157: Remove this use of "getDataProvider"; it is deprecated. rule
  7. MINOR CheckboxGroup.java#L171: Remove this use of "getDataProvider"; it is deprecated. rule
  8. MINOR CheckboxGroup.java#L432: Remove this use of "getDataProvider"; it is deprecated. rule
  9. MINOR CheckboxGroup.java#L472: Remove this use of "getDataProvider"; it is deprecated. rule
  10. MINOR CheckboxGroup.java#L611: Remove this use of "getDataProvider"; it is deprecated. rule

@sosa-vaadin sosa-vaadin merged commit eaf6e7a into master Aug 2, 2021
@sosa-vaadin sosa-vaadin deleted the fix/1185 branch August 2, 2021 06:50
ZheSun88 pushed a commit that referenced this pull request Aug 2, 2021
…1903)

Co-authored-by: Sascha Ißbrücker <sascha.issbruecker@googlemail.com>
Co-authored-by: Guille <alvarezguille@users.noreply.github.com>
ZheSun88 pushed a commit that referenced this pull request Aug 2, 2021
…1903)

Co-authored-by: Sascha Ißbrücker <sascha.issbruecker@googlemail.com>
Co-authored-by: Guille <alvarezguille@users.noreply.github.com>
ZheSun88 pushed a commit that referenced this pull request Aug 2, 2021
…1903)

Co-authored-by: Sascha Ißbrücker <sascha.issbruecker@googlemail.com>
Co-authored-by: Guille <alvarezguille@users.noreply.github.com>
ZheSun88 pushed a commit that referenced this pull request Aug 2, 2021
…1903)

Co-authored-by: Sascha Ißbrücker <sascha.issbruecker@googlemail.com>
Co-authored-by: Guille <alvarezguille@users.noreply.github.com>
alvarezguille added a commit that referenced this pull request Aug 3, 2021
…esn't change (#1903) (#1967)

Co-authored-by: David Sosa <76832183+sosa-vaadin@users.noreply.github.com>
Co-authored-by: Sascha Ißbrücker <sascha.issbruecker@googlemail.com>
Co-authored-by: Guille <alvarezguille@users.noreply.github.com>
alvarezguille added a commit that referenced this pull request Aug 3, 2021
…esn't change (#1903) (#1968)

Co-authored-by: Sascha Ißbrücker <sascha.issbruecker@googlemail.com>
Co-authored-by: Guille <alvarezguille@users.noreply.github.com>

Co-authored-by: David Sosa <76832183+sosa-vaadin@users.noreply.github.com>
Co-authored-by: Sascha Ißbrücker <sascha.issbruecker@googlemail.com>
Co-authored-by: Guille <alvarezguille@users.noreply.github.com>
alvarezguille added a commit that referenced this pull request Aug 3, 2021
…esn't change (#1903) (#1969)

Co-authored-by: David Sosa <76832183+sosa-vaadin@users.noreply.github.com>
Co-authored-by: Sascha Ißbrücker <sascha.issbruecker@googlemail.com>
Co-authored-by: Guille <alvarezguille@users.noreply.github.com>
alvarezguille added a commit that referenced this pull request Aug 3, 2021
…esn't change (#1903) (#1970)

Co-authored-by: Sascha Ißbrücker <sascha.issbruecker@googlemail.com>
Co-authored-by: Guille <alvarezguille@users.noreply.github.com>

Co-authored-by: David Sosa <76832183+sosa-vaadin@users.noreply.github.com>
Co-authored-by: Sascha Ißbrücker <sascha.issbruecker@googlemail.com>
Co-authored-by: Guille <alvarezguille@users.noreply.github.com>
@vaadin-bot
Copy link
Collaborator

This ticket/PR has been released with platform 22.0.0.alpha1 and is also targeting the upcoming stable 22.0.0 version.

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.

CheckBoxGroup: Selection issue when using ItemEnabledProvider
5 participants