Skip to content

Commit

Permalink
feat: support reverse button collapsing order in menu-bar (#6048) (#6056
Browse files Browse the repository at this point in the history
)
  • Loading branch information
tomivirkki authored Feb 16, 2024
1 parent 13eb3da commit a22be12
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,30 @@ public void removeThemeVariants(MenuBarVariant... variants) {
.collect(Collectors.toList()));
}

/**
* Sets reverse collapse order for the menu bar.
*
* @param reverseCollapseOrder
* If {@code true}, the buttons will be collapsed into the
* overflow menu starting from the "start" end of the bar instead
* of the "end".
*/
public void setReverseCollapseOrder(boolean reverseCollapseOrder) {
getElement().setProperty("reverseCollapse", reverseCollapseOrder);
}

/**
* Gets whether the menu bar uses reverse collapse order.
*
* @return {@code true} if the buttons will be collapsed into the overflow
* menu starting from the "start" end of the bar instead of the
* "end".
*
*/
public boolean isReverseCollapseOrder() {
return getElement().getProperty("reverseCollapse", false);
}

/**
* Gets the internationalization object previously set for this component.
* <p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,21 @@ public void setOpenOnHover_isOpenOnHover() {
Assert.assertTrue(menuBar.isOpenOnHover());
}

@Test
public void isReverseCollapseOrder() {
Assert.assertFalse(menuBar.isReverseCollapseOrder());
Assert.assertFalse(
menuBar.getElement().getProperty("reverseCollapse", false));
}

@Test
public void setReverseCollapseOrder_isReverseCollapseOrder() {
menuBar.setReverseCollapseOrder(true);
Assert.assertTrue(menuBar.isReverseCollapseOrder());
Assert.assertTrue(
menuBar.getElement().getProperty("reverseCollapse", false));
}

private void assertChildrenAndItems(MenuItem... expected) {
Object[] menuItems = menuBar.getChildren().toArray();
Assert.assertArrayEquals(expected, menuItems);
Expand Down

0 comments on commit a22be12

Please sign in to comment.