Skip to content

Commit

Permalink
fix: associate caption label with the component
Browse files Browse the repository at this point in the history
Close #159
  • Loading branch information
javier-godoy authored and paodb committed Oct 2, 2023
1 parent dbf63f8 commit dbdff2f
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ public enum Orientation {

private boolean isFromClient = false;

private String layoutId;

private static <T> ListDataProvider<T> emptyDataProvider() {
return DataProvider.ofCollection(new LinkedHashSet<>());
}
Expand Down Expand Up @@ -311,6 +313,7 @@ public void setCaption(String captionText) {
if (captionText != null) {
if (captionLabel == null) {
captionLabel = new Label();
captionLabel.setFor(layoutId);
addComponentAsFirst(captionLabel);
}
captionLabel.setText(captionText);
Expand Down Expand Up @@ -387,6 +390,12 @@ private Component createContainerLayout() {
throw new IllegalStateException();
}

private String getLayoutId() {
return Optional.ofNullable(layoutId).orElseGet(()->{
return this.layoutId = "twincol-" + UUID.randomUUID();
});
}

private HorizontalLayout createHorizontalContainer(boolean reverse) {
buttonContainer = getVerticalButtonContainer();
HorizontalLayout hl;
Expand All @@ -395,6 +404,7 @@ private HorizontalLayout createHorizontalContainer(boolean reverse) {
} else {
hl = new HorizontalLayout(available.layout, buttonContainer, selection.layout);
}
hl.setId(getLayoutId());
hl.getElement().getStyle().set("min-height", "0px");
hl.getElement().getStyle().set("flex", "1 1 0px");
hl.setMargin(false);
Expand All @@ -410,6 +420,7 @@ private VerticalLayout createVerticalContainer(boolean reverse) {
} else {
vl = new VerticalLayout(available.layout, buttonContainer, selection.layout);
}
vl.setId(getLayoutId());
vl.getElement().getStyle().set("min-width", "0px");
vl.getElement().getStyle().set("flex", "1 1 0px");
vl.setMargin(false);
Expand Down

0 comments on commit dbdff2f

Please sign in to comment.