summaryrefslogtreecommitdiffstats
path: root/client/src
diff options
context:
space:
mode:
authorAnsku <Ansku@users.noreply.github.com>2017-11-10 16:50:27 +0200
committerPéter Török <31210544+torok-peter@users.noreply.github.com>2017-11-10 16:50:27 +0200
commitbcdd76c6a006a8d0f27f22c6078814ff2b4b09dc (patch)
tree117759e5ef9195ae9678ab5e33ca7be67d0b12fd /client/src
parent37bd6b1a32c9d5d6a53755de8bb1a94556b4471b (diff)
downloadvaadin-framework-bcdd76c6a006a8d0f27f22c6078814ff2b4b09dc.tar.gz
vaadin-framework-bcdd76c6a006a8d0f27f22c6078814ff2b4b09dc.zip
Fix setting custom tab index for TabSheet or Accordion (#9574) (#10278)
Diffstat (limited to 'client/src')
-rw-r--r--client/src/main/java/com/vaadin/client/ui/VAccordion.java18
-rw-r--r--client/src/main/java/com/vaadin/client/ui/VTabsheet.java14
2 files changed, 32 insertions, 0 deletions
diff --git a/client/src/main/java/com/vaadin/client/ui/VAccordion.java b/client/src/main/java/com/vaadin/client/ui/VAccordion.java
index 9ad4ef4e96..c103f9e726 100644
--- a/client/src/main/java/com/vaadin/client/ui/VAccordion.java
+++ b/client/src/main/java/com/vaadin/client/ui/VAccordion.java
@@ -51,6 +51,8 @@ public class VAccordion extends VTabsheetBase {
private final TouchScrollHandler touchScrollHandler;
+ private int tabulatorIndex;
+
public VAccordion() {
super(CLASSNAME);
@@ -110,6 +112,20 @@ public class VAccordion extends VTabsheetBase {
}
}
+ /**
+ * For internal use only. May be renamed or removed in a future release.
+ *
+ * @param tabIndex
+ * tabulator index for the open stack item
+ */
+ public void setTabIndex(int tabIndex) {
+ tabulatorIndex = tabIndex;
+ StackItem openStackItem = getOpenStackItem();
+ if (openStackItem != null) {
+ openStackItem.getElement().setTabIndex(tabIndex);
+ }
+ }
+
/** For internal use only. May be removed or replaced in the future. */
public void open(int itemIndex) {
StackItem item = (StackItem) getWidget(itemIndex);
@@ -308,6 +324,7 @@ public class VAccordion extends VTabsheetBase {
content.getStyle().setLeft(0, Unit.PX);
content.getStyle().clearVisibility();
addStyleDependentName("open");
+ getElement().setTabIndex(tabulatorIndex);
}
public void hide() {
@@ -325,6 +342,7 @@ public class VAccordion extends VTabsheetBase {
setHeight(-1);
setWidth("");
open = false;
+ getElement().setTabIndex(-1);
}
public boolean isOpen() {
diff --git a/client/src/main/java/com/vaadin/client/ui/VTabsheet.java b/client/src/main/java/com/vaadin/client/ui/VTabsheet.java
index e3e55f97ef..c9c721bbe9 100644
--- a/client/src/main/java/com/vaadin/client/ui/VTabsheet.java
+++ b/client/src/main/java/com/vaadin/client/ui/VTabsheet.java
@@ -787,6 +787,20 @@ public class VTabsheet extends VTabsheetBase
private String currentStyle;
/**
+ * For internal use only. May be renamed or removed in a future release.
+ *
+ * @param tabIndex
+ * tabulator index for the active tab of the tab sheet
+ */
+ public void setTabIndex(int tabIndex) {
+ tabulatorIndex = tabIndex;
+ Tab activeTab = getActiveTab();
+ if (activeTab != null) {
+ activeTab.setTabulatorIndex(tabIndex);
+ }
+ }
+
+ /**
* @return Whether the tab could be selected or not.
*/
private boolean canSelectTab(final int tabIndex) {