vaadin / vaadin-button-flow

Vaadin Flow Java API for vaadin/vaadin-button Web Component
https://vaadin.com/components/vaadin-button
Other
0 stars 8 forks source link

Removal of slot prefix from Image when calling setText on the button. #73

Closed bisam-rd closed 6 years ago

bisam-rd commented 6 years ago

When calling setText on a button with an icon as prefix, the icon is removed from the prefix slot which can cause aligment problems between the image and the label.

Code pointer : GeneratedVaadinButton.class protected void removeAll() { getElement().getChildren() .forEach(child -> child.removeAttribute("slot")); getElement().removeAllChildren(); }

Code Sample :

Button btnWithIconSlotted=new Button("Button On SlotPrefix"); Icon icon = new Icon(VaadinIcon.BULLSEYE); icon.getElement().setAttribute("slot","prefix"); btnWithIconSlotted.setIcon(icon);

Button button = new Button("change Text of Slotted", event -> btnWithIconSlotted.setText("Button No More On SlotPrefix"));

add(btnWithIconSlotted, button);