Skip to content

Commit 45e3af5

Browse files
committed
fix #966 add findTabByKey to tabs
1 parent 20eda8b commit 45e3af5

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

domino-ui/src/main/java/org/dominokit/domino/ui/tabs/TabsPanel.java

+13-5
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,13 @@
1919
import static java.util.Objects.nonNull;
2020
import static org.dominokit.domino.ui.utils.Domino.*;
2121

22-
import elemental2.dom.DomGlobal;
2322
import elemental2.dom.Element;
2423
import elemental2.dom.HTMLDivElement;
2524
import java.util.ArrayList;
2625
import java.util.Arrays;
2726
import java.util.List;
27+
import java.util.Objects;
28+
import java.util.Optional;
2829
import java.util.function.Consumer;
2930
import org.dominokit.domino.ui.IsElement;
3031
import org.dominokit.domino.ui.animations.Animation;
@@ -424,13 +425,20 @@ public TabsPanel activateByKey(String key) {
424425
* @return the current {@link TabsPanel} instance.
425426
*/
426427
public TabsPanel activateByKey(String key, boolean silent) {
427-
tabs.stream()
428-
.filter(tab -> tab.getKey().equalsIgnoreCase(key))
429-
.findFirst()
430-
.ifPresent(tab -> activateTab(tab, silent));
428+
findByKey(key).ifPresent(tab -> activateTab(tab, silent));
431429
return this;
432430
}
433431

432+
/**
433+
* Finds the first tab by the specified key. this is a case-sensitive search
434+
*
435+
* @param key The tab key
436+
* @return Optional of a tab.
437+
*/
438+
public Optional<Tab> findByKey(String key) {
439+
return tabs.stream().filter(tab -> Objects.equals(tab.getKey(), key)).findFirst();
440+
}
441+
434442
/**
435443
* Checks if the auto-activation feature is enabled. When auto-activation is enabled, the first
436444
* tab added to the tabs panel will automatically be set as active.

0 commit comments

Comments
 (0)