Skip to content

Commit

Permalink
feat: add constructor allowing to set Popover content (#6558)
Browse files Browse the repository at this point in the history
Co-authored-by: Sascha Ißbrücker <[email protected]>
  • Loading branch information
web-padawan and sissbruecker authored Aug 20, 2024
1 parent 89b323d commit 0f09065
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,18 @@ public Popover() {
setOverlayRole("dialog");
}

/**
* Creates a popover with given components inside.
*
* @param components
* the components inside the popover
* @see #add(Component...)
*/
public Popover(Component... components) {
this();
add(components);
}

/**
* {@code opened-changed} event is sent when the overlay opened state
* changes.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,4 +274,13 @@ public void setAutofocus_isAutofocus() {
Assert.assertTrue(popover.isAutofocus());
Assert.assertTrue(popover.getElement().getProperty("autofocus", false));
}

@Test
public void popoverWithContent() {
Div content = new Div();
Popover popoverWithContent = new Popover(content);
Assert.assertEquals(1, popoverWithContent.getChildren().count());
Assert.assertSame(content,
popoverWithContent.getChildren().findFirst().get());
}
}

0 comments on commit 0f09065

Please sign in to comment.