vaadin / collaboration-engine

The simplest way to build real-time collaboration into web apps
https://vaadin.com/collaboration
Other
3 stars 1 forks source link

CollaborationAvatarGroup does not work within a Dialog #5

Closed Peppe closed 3 years ago

Peppe commented 3 years ago

Describe the bug This is a report from the customer during a call. Needs verification.

According to the customer, if you put CollaborationAvatarGroup into a Dialog in Vaadin, the component does not show.

To Reproduce Steps to reproduce the behavior:

  1. Create a Dialog
  2. Create a CollaborationAvatarGroup and put it into the Dialog
  3. Open Dialog in browser
  4. No Avatar group visible.

Versions

Peppe commented 3 years ago

I was not able to reproduce the bug. Both AvatarGroup and CollaborationAvatarGroup showed up correctly. Can anyone share more details under what circumstances CollaborationAvatarGroup does not work in a Dialog? A test case would be highly appreciated.

Screenshot Screenshot 2020-10-23 at 11 06 40

Test case

package com.vaadin.collaborationengine;

import java.math.BigDecimal;
import java.util.concurrent.atomic.AtomicInteger;

import com.vaadin.flow.component.avatar.AvatarGroup;
import com.vaadin.flow.component.button.Button;
import com.vaadin.flow.component.dialog.Dialog;
import com.vaadin.flow.component.html.Paragraph;
import com.vaadin.flow.component.html.Span;
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
import com.vaadin.flow.component.page.Push;
import com.vaadin.flow.component.textfield.BigDecimalField;
import com.vaadin.flow.component.textfield.TextField;
import com.vaadin.flow.router.Route;

@Push
@Route("playground")
public class PlaygroundView extends VerticalLayout {

    public static final String TOPIC_ID = "topic";

    CollaborationAvatarGroup avatars;

    TextField textField = new TextField("Name");
    BigDecimalField bigDecimalField = new BigDecimalField("Money on bank");

    CollaborationBinder<Person> binder;

    static AtomicInteger userCounter = new AtomicInteger(0);

    public class Person {
        private String name;
        private BigDecimal bankAccount;

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public BigDecimal getBankAccount() {
            return bankAccount;
        }

        public void setBankAccount(BigDecimal bankAccount) {
            this.bankAccount = bankAccount;
        }
    }

    public PlaygroundView() {
        int userIndex = userCounter.incrementAndGet();

        UserInfo localUser = new UserInfo("userId-" + userIndex);
        localUser.setName("User " + userIndex);
        avatars = new CollaborationAvatarGroup(localUser, TOPIC_ID);

        bigDecimalField.setPrefixComponent(new Span("€"));
        add(new Paragraph("hello world"));

        add(avatars, textField, bigDecimalField);

        binder = new CollaborationBinder<>(Person.class, localUser);
        binder.setTopic(TOPIC_ID, () -> null);
        binder.bind(textField, "name");
        binder.bind(bigDecimalField, "bankAccount");

        Button button = new Button("Open dialog", (click) -> {
            AvatarGroup group = new AvatarGroup();
            group.add(new AvatarGroup.AvatarGroupItem("Jens"),
                    new AvatarGroup.AvatarGroupItem("Pekka"),
                    new AvatarGroup.AvatarGroupItem("Leif"));
            CollaborationAvatarGroup cGroup = new CollaborationAvatarGroup(
                    localUser, "dialog");
            Dialog dialog = new Dialog(new Paragraph("AvatarGroup"), group,
                    new Paragraph("CollaborationAvatarGroup"), cGroup);
            dialog.open();
        });
        add(button);
    }

}
chrosim commented 3 years ago

It is possible that it never was a problem, but instead was related to the big-decimal-field bug

Peppe commented 3 years ago

Okay, good. I'll close this issue for now. Open it again if it re-appears.