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

feat: support reverse button collapsing order in menu-bar #6048

Merged
merged 2 commits into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,30 @@ public boolean isOpenOnHover() {
return getElement().getProperty("openOnHover", false);
}

/**
* 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 @@ -93,6 +93,21 @@ public void implementsHasOverlayClassName() {
.isAssignableFrom(new MenuBar().getClass()));
}

@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