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

Provide collection based methods for HasComponents #13598

Closed
stefanuebe opened this issue Apr 22, 2022 · 1 comment · Fixed by #14202
Closed

Provide collection based methods for HasComponents #13598

stefanuebe opened this issue Apr 22, 2022 · 1 comment · Fixed by #14202

Comments

@stefanuebe
Copy link
Contributor

stefanuebe commented Apr 22, 2022

Describe your motivation

Currently it is not simply possible to add/remove a collection of components to/from another component. It first has to be converted to an array. That feels clumsy and incomplete.

Describe the solution you'd like

Provide new, collection based add and remove methods to HasComponents which do the same as the varargs variants, e.g.

public interface HasComponents extends HasElement, HasEnabled { 
    default void add(Collection<Component> components) {
        Objects.requireNonNull(components, "Components should not be null");
        for (Component component : components) {
            Objects.requireNonNull(component,
                    "Component to add cannot be null");
            getElement().appendChild(component.getElement());
        }
    }

    // analog for remove(Collection<Component> components)
}
@MarcinVaadin MarcinVaadin self-assigned this Jul 22, 2022
@MarcinVaadin MarcinVaadin linked a pull request Jul 22, 2022 that will close this issue
9 tasks
mshabarov pushed a commit that referenced this issue Jul 29, 2022
Added Collection based add / remove methods for com.vaadin.flow.component.HasComponents

Fixes #13598
@vaadin-bot
Copy link
Collaborator

This ticket/PR has been released with Vaadin 23.2.0.beta1 and is also targeting the upcoming stable 23.2.0 version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment