Skip to content

Commit

Permalink
fix: allow null items in RadioButtonGroup (#514) (#517)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomivirkki committed Dec 10, 2020
1 parent b1c05ac commit e32fc7b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ private void setupDataProviderListener(DataProvider<T, ?> dataProvider) {
@Override
public void setValue(T value) {
super.setValue(value);
getRadioButtons().forEach(rb -> rb.setChecked(rb.getItem().equals(value)));
getRadioButtons().forEach(rb -> rb.setChecked(Objects.equals(rb.getItem(), value)));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -381,4 +381,12 @@ public void setIdentifierProviderOnId_setItemWithNullId_shouldFailToSelectExisti
radioButtonGroup.setValue(new CustomItem(null, "First"));
Assert.assertNull(radioButtonGroup.getValue().getId());
}

@Test
public void addNullOption_setValue() {
RadioButtonGroup<String> group = new RadioButtonGroup<>();
group.setItems("enabled", "disabled", null);
group.setValue(null);
Assert.assertEquals(group.getValue(), null);
}
}

0 comments on commit e32fc7b

Please sign in to comment.