Skip to content

Commit

Permalink
fix: make radio button group with size request serializable (#6571)
Browse files Browse the repository at this point in the history
  • Loading branch information
sissbruecker authored and vaadin-bot committed Aug 23, 2024
1 parent 8f83483 commit 5d24302
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -578,9 +578,15 @@ private void reset() {
// Ignore new size requests unless the last one has been executed
// so as to avoid multiple beforeClientResponses.
if (sizeRequest == null) {
sizeRequest = ui -> {
fireSizeEvent();
sizeRequest = null;
// Using anonymous class to fix serialization issue:
// https://github.com/vaadin/flow-components/issues/6555
// Do not replace with lambda
sizeRequest = new SerializableConsumer<>() {
@Override
public void accept(UI ui) {
fireSizeEvent();
sizeRequest = null;
}
};
// Size event is fired before client response so as to avoid
// multiple size change events during server round trips
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,23 @@
*/
package com.vaadin.flow.component.radiobutton.tests;

import org.junit.Test;

import com.vaadin.flow.component.UI;
import com.vaadin.flow.component.radiobutton.RadioButtonGroup;
import com.vaadin.flow.testutil.ClassesSerializableTest;

public class RadioButtonSerializableTest extends ClassesSerializableTest {
@Test
public void setItems_addToUI_radioButtonGroupIsSerializable()
throws Throwable {
var group = new RadioButtonGroup<>();
group.setItems("Item 1", "Item 2");

var ui = new UI();
UI.setCurrent(ui);
ui.add(group);

serializeAndDeserialize(ui);
}
}

0 comments on commit 5d24302

Please sign in to comment.