Skip to content

Commit

Permalink
fix #953 Clearing the search in a grouped select does not restore all…
Browse files Browse the repository at this point in the history
… options
  • Loading branch information
vegegoku committed Sep 22, 2024
1 parent d7e3e4e commit 4864029
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import static java.util.Objects.nonNull;

import java.util.Objects;
import java.util.Optional;
import org.dominokit.domino.ui.elements.DivElement;

/**
Expand Down Expand Up @@ -73,14 +74,14 @@ public Select(String label) {
}

protected void doSetValue(V value, boolean silent) {
findOptionByValue(value)
.ifPresentOrElse(
vSelectOption -> onOptionSelected(vSelectOption, isChangeListenersPaused()),
() -> {
if (isNull(value)) {
clearValue(silent);
}
});
Optional<SelectOption<V>> option = findOptionByValue(value);
if (option.isPresent()) {
onOptionSelected(option.get(), isChangeListenersPaused());
} else {
if (isNull(value)) {
clearValue(silent);
}
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,23 @@ public MenuItemsGroup<V> withClickableElement(
* Invoked during a search operation across all the menu items in this group.
*
* @param token the search token
* @param caseSensitive indicates if the search should be case sensitive or not
* @param caseSensitive indicates if the search should be case-sensitive or not
* @return true if any of the menu items match the token; false otherwise
*/
@Override
public boolean onSearch(String token, boolean caseSensitive) {
return menuItems.stream().anyMatch(menuItem -> menuItem.onSearch(token, caseSensitive));
boolean result = true;
boolean anyMatch = false;
for (int index = 0; index < menuItems.size(); index++) {
boolean found = menuItems.get(index).onSearch(token, caseSensitive);
anyMatch |= found;
result &= found;
}
if (anyMatch) {
this.show();
} else {
this.hide();
}
return result;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,21 @@ a.dui-menu-group-header:focus,
a.dui-menu-group-header {
text-decoration: none;
outline: none;
display: inherit;
display: flex;
}

a.dui-menu-group-header .dui-menu-item-nested-indicator:empty,
a.dui-menu-group-header .dui-menu-item-postfix:empty,
a.dui-menu-group-header .dui-menu-item-prefix:empty {
display: none;
}

a.dui-menu-group-header .dui-menu-item-body {
max-width: calc(100%);
}

a.dui-menu-group-header .dui-menu-item-prefix:empty {
display: none;
}

.dui-menu-group-header-nav {
Expand Down

0 comments on commit 4864029

Please sign in to comment.