Skip to content

Commit

Permalink
Add missing JavaDocs and since tags (#10372)
Browse files Browse the repository at this point in the history
  • Loading branch information
tsuoanttila committed Nov 27, 2017
1 parent 3fb74c1 commit 1277ebb
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
28 changes: 24 additions & 4 deletions client/src/main/java/com/vaadin/client/ui/FocusUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,22 +97,42 @@ public static int getTabIndex(Widget focusable) {
return focusable.getElement().getTabIndex();
}

/**
* Finds all the focusable children of given parent element.
*
* @param parent
* the parent element
* @return array of focusable children
* @since 8.1.7
*/
public static native Element[] getFocusableChildren(Element parent)
/*-{
var focusableChildren = parent.querySelectorAll('[type][tabindex]:not([tabindex="-1"]), [role=button][tabindex]:not([tabindex="-1"])');
return focusableChildren;
}-*/;

public static void focusOnFirstFocusableElement(Element parent)
{
/**
* Moves the focus to the first focusable child of given parent element.
*
* @param parent
* the parent element
* @since 8.1.7
*/
public static void focusOnFirstFocusableElement(Element parent) {
Element[] focusableChildren = getFocusableChildren(parent);
if (focusableChildren.length > 0) {
focusableChildren[0].focus();
}
}

public static void focusOnLastFocusableElement(Element parent)
{
/**
* Moves the focus to the last focusable child of given parent element.
*
* @param parent
* the parent element
* @since 8.1.7
*/
public static void focusOnLastFocusableElement(Element parent) {
Element[] focusableChildren = getFocusableChildren(parent);
if (focusableChildren.length > 0) {
focusableChildren[focusableChildren.length - 1].focus();
Expand Down
1 change: 1 addition & 0 deletions client/src/main/java/com/vaadin/client/ui/VAccordion.java
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ protected void updateStyleNames(String primaryStyleName) {
*
* @param tabIndex
* tabulator index for the open stack item
* @since 8.1.7
*/
public void setTabIndex(int tabIndex) {
tabulatorIndex = tabIndex;
Expand Down
1 change: 1 addition & 0 deletions client/src/main/java/com/vaadin/client/ui/VTabsheet.java
Original file line number Diff line number Diff line change
Expand Up @@ -793,6 +793,7 @@ private void recalculateCaptionWidths() {
*
* @param tabIndex
* tabulator index for the active tab of the tab sheet
* @since 8.1.7
*/
public void setTabIndex(int tabIndex) {
tabulatorIndex = tabIndex;
Expand Down

0 comments on commit 1277ebb

Please sign in to comment.