Problem with reset of RadioButtonGroup in Flow

Hi there,

I have a problem when resetting the value of a RadioButtonGroup if this component is reused (e.g. in a Dialog). The last value is still selected in the frontent even if I reset the value to empty in the backend before.
Here is a sample code:

enum TestEnum {
		A,
		B,
		C
	}

	public MainView() {

		CheckboxGroup<TestEnum> checkboxGroup = new CheckboxGroup<>();
		checkboxGroup.setDataProvider(new ListDataProvider<TestEnum>(Arrays.asList(TestEnum.values())));
		checkboxGroup.setValue(checkboxGroup.getEmptyValue());

		Dialog dialog = new Dialog();
		dialog.add(checkboxGroup);

		Button button = new Button("Click me",
				event -> {

					Notification.show("Length of valueset before reset:" + checkboxGroup.getValue().size()
							+ " Selected:" + checkboxGroup.getValue());
					checkboxGroup.setValue(checkboxGroup.getEmptyValue());
					checkboxGroup.deselectAll();
					Notification.show("Length of valueset after reset:" + checkboxGroup.getValue().size() + " Selected:"
							+ checkboxGroup.getValue());
					dialog.open();

				});

		add(button);
	}

Scenario:

  • Click the button
  • Select something
  • close the dialog by clicking outside of it
  • Click the button again…
  • You will see that the Item is still selected even though the RadioButtonGroup is set to emptyValue before, I also tried deselectAll().

What am I doing wrong here?

Hi! I tested this quickly with Vaadin 13.0.3, and deselectAll() does work. What version are you running?

I’m using 13.0.3.

Did you test it the way I did (reused RadioButtonGroup in a Dialog?)

Wow, you are right, that is some weird behaviour. Could you [create a ticket]
(https://github.com/vaadin/vaadin-checkbox-flow/issues), please?

Sure, I will.

Thanks for now

Just fyi, I create the following ticket:

https://github.com/vaadin/vaadin-checkbox-flow/issues/101

Is someone looking into this issue? I did not see any reaction on it yet…

We will try take care of that asap, probably during the next sprint.

Thanks alot :slight_smile: