|
19 | 19 | import static java.util.Objects.nonNull;
|
20 | 20 | import static org.dominokit.domino.ui.utils.Domino.*;
|
21 | 21 |
|
22 |
| -import elemental2.dom.DomGlobal; |
23 | 22 | import elemental2.dom.Element;
|
24 | 23 | import elemental2.dom.HTMLDivElement;
|
25 | 24 | import java.util.ArrayList;
|
26 | 25 | import java.util.Arrays;
|
27 | 26 | import java.util.List;
|
| 27 | +import java.util.Objects; |
| 28 | +import java.util.Optional; |
28 | 29 | import java.util.function.Consumer;
|
29 | 30 | import org.dominokit.domino.ui.IsElement;
|
30 | 31 | import org.dominokit.domino.ui.animations.Animation;
|
@@ -424,13 +425,20 @@ public TabsPanel activateByKey(String key) {
|
424 | 425 | * @return the current {@link TabsPanel} instance.
|
425 | 426 | */
|
426 | 427 | 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)); |
431 | 429 | return this;
|
432 | 430 | }
|
433 | 431 |
|
| 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 | + |
434 | 442 | /**
|
435 | 443 | * Checks if the auto-activation feature is enabled. When auto-activation is enabled, the first
|
436 | 444 | * tab added to the tabs panel will automatically be set as active.
|
|
0 commit comments