diff options
author | Olli Tietäväinen <ollit@vaadin.com> | 2018-01-24 11:29:10 +0200 |
---|---|---|
committer | Teemu Suo-Anttila <tsuoanttila@users.noreply.github.com> | 2018-01-24 11:29:10 +0200 |
commit | 881d80fd8b658491e26125222020401d0e5a5d08 (patch) | |
tree | 98f5d023118147e0ff70843a023c1de09acc3beb /client | |
parent | 2c3df1adfdecdda7747ec63b00ab4a6c5e1315d3 (diff) | |
download | vaadin-framework-881d80fd8b658491e26125222020401d0e5a5d08.tar.gz vaadin-framework-881d80fd8b658491e26125222020401d0e5a5d08.zip |
Make modal window focus circulate correctly (#10497)
Diffstat (limited to 'client')
-rw-r--r-- | client/src/main/java/com/vaadin/client/ui/FocusUtil.java | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/client/src/main/java/com/vaadin/client/ui/FocusUtil.java b/client/src/main/java/com/vaadin/client/ui/FocusUtil.java index 0f517d89ed..fe0f765f47 100644 --- a/client/src/main/java/com/vaadin/client/ui/FocusUtil.java +++ b/client/src/main/java/com/vaadin/client/ui/FocusUtil.java @@ -119,8 +119,17 @@ public class FocusUtil { */ public static void focusOnFirstFocusableElement(Element parent) { Element[] focusableChildren = getFocusableChildren(parent); - if (focusableChildren.length > 0) { - focusableChildren[0].focus(); + if (focusableChildren.length == 0) { + return; + } + // find the first element that doesn't have "disabled" in the class name + for (int i = 0; i < focusableChildren.length; i++) { + Element element = focusableChildren[i]; + String classes = element.getAttribute("class"); + if (classes == null || !classes.toLowerCase().contains("disabled")) { + element.focus(); + return; + } } } |