Skip to content

Commit

Permalink
fix #867 Moving focus from Select element
Browse files Browse the repository at this point in the history
  • Loading branch information
vegegoku committed Oct 30, 2023
1 parent 54b0e0c commit 3748613
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,19 @@ default NumberParsers getNumberParsers() {
return new NumberParsers() {};
}

/**
* Use this method to configure if pressing tab while select field is focused will move the focus
* to the select arrow addon or not.
*
* <p>Defaults to : <b>false</b>
*
* @return a boolean, <b>true</b> to enable focus on select arrow by pressing tab, <b>false</b>
* disable focus on select arrow when pressing tab.
*/
default boolean isTabFocusSelectArrowEnabled() {
return false;
}

/**
* Use this method to define the default position of the field label, top or left
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,21 @@ public AbstractSelect() {
Icons.chevron_down()
.addCss(dui_form_select_drop_arrow)
.clickable()
.setAttribute("tabindex", getConfig().isTabFocusSelectArrowEnabled() ? "0" : "-1")
.setAttribute(
"aria-expanded", getConfig().isTabFocusSelectArrowEnabled() ? "true" : "false")
.addClickListener(
evt -> {
evt.stopPropagation();
openOptionMenu();
})));
})
.onKeyPress(
keyEvents ->
keyEvents.onEnter(
evt -> {
evt.stopPropagation();
openOptionMenu();
}))));

appendChild(
PrimaryAddOn.of(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package org.dominokit.domino.ui.forms.suggest;

import static java.util.Objects.isNull;
import static java.util.Objects.nonNull;

import java.util.Objects;
Expand Down Expand Up @@ -105,7 +106,7 @@ protected void onOptionSelected(SelectOption<V> option, boolean silent) {
@Override
public Select<V> withOption(SelectOption<V> option, boolean silent) {
V oldValue = getValue();
if (!Objects.equals(option.getValue(), oldValue)) {
if (!Objects.equals(option.getValue(), oldValue) || isNull(oldValue)) {
doSetOption(option);

updateTextValue();
Expand Down

0 comments on commit 3748613

Please sign in to comment.