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: make radio button group with size request serializable (#6571) (CP: 24.4) #6573

Merged
merged 1 commit into from
Aug 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -608,9 +608,15 @@ private void rebuild() {
// 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);
}
}