Skip to content
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 @@ -519,6 +519,30 @@ public boolean isVisible() {
return true;
}

/**
* Sets the root heading level used by sections and widgets, which controls
* their <code>aria-level</code> attributes on title elements. The nested
* widgets will have their {@code aria-level} one higher than the root
* heading level.
* <p>
* For example, if root heading level is set to {@code 1}:
* <ul>
* <li>Sections and non-nested widgets will have {@code aria-level="1"}</li>
* <li>Nested widgets will have {@code aria-level="2"}</li>
* </ul>
* Setting it {@code null} resets it to the default value of {@code 2}.
*
* @param rootHeadingLevel
* the root heading level property, {@code null} to remove
*/
public void setRootHeadingLevel(Integer rootHeadingLevel) {
if (rootHeadingLevel == null) {
getElement().removeProperty("rootHeadingLevel");
} else {
getElement().setProperty("rootHeadingLevel", rootHeadingLevel);
}
}

@Override
protected void onAttach(AttachEvent attachEvent) {
super.onAttach(attachEvent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1074,6 +1074,26 @@ public void changeWidgetInSectionSelectedState_eventCorrectlyFired() {
assertItemSelectedChangedEventCorrectlyFired(widget, false);
}

@Test
public void setRootHeadingLevel_elementPropertyIsUpdated() {
var rootHeadingLevel = 1;
dashboard.setRootHeadingLevel(rootHeadingLevel);
Assert.assertEquals(rootHeadingLevel,
dashboard.getElement().getProperty("rootHeadingLevel", -1));
rootHeadingLevel = 7;
dashboard.setRootHeadingLevel(rootHeadingLevel);
Assert.assertEquals(rootHeadingLevel,
dashboard.getElement().getProperty("rootHeadingLevel", -1));
}

@Test
public void setTitleHeadingLevelNull_elementPropertyIsRemoved() {
dashboard.setRootHeadingLevel(1);
dashboard.setRootHeadingLevel(null);
Assert.assertFalse(
dashboard.getElement().hasProperty("rootHeadingLevel"));
}

private void assertItemSelectedChangedEventCorrectlyFired(Component item,
boolean selected) {
AtomicInteger listenerInvokedCount = new AtomicInteger(0);
Expand Down