diff --git a/app/src/main/java/io/xpipe/app/hub/comp/StoreCreationDialog.java b/app/src/main/java/io/xpipe/app/hub/comp/StoreCreationDialog.java index edbd527d2..f3abbccd4 100644 --- a/app/src/main/java/io/xpipe/app/hub/comp/StoreCreationDialog.java +++ b/app/src/main/java/io/xpipe/app/hub/comp/StoreCreationDialog.java @@ -63,9 +63,7 @@ public class StoreCreationDialog { .getStoreCategoryIfPresent(e.getCategoryUuid()) .orElseThrow(); PlatformThread.runLaterIfNeeded(() -> { - StoreViewState.get() - .getActiveCategory() - .setValue(StoreViewState.get().getCategoryWrapper(cat)); + StoreViewState.get().selectCategoryIntoViewIfNeeded(StoreViewState.get().getCategoryWrapper(cat)); }); c.accept(e); @@ -106,9 +104,7 @@ public class StoreCreationDialog { .getStoreCategoryIfPresent(e.getCategoryUuid()) .orElseThrow(); PlatformThread.runLaterIfNeeded(() -> { - StoreViewState.get() - .getActiveCategory() - .setValue(StoreViewState.get().getCategoryWrapper(cat)); + StoreViewState.get().selectCategoryIntoViewIfNeeded(StoreViewState.get().getCategoryWrapper(cat)); }); } } catch (Exception ex) { diff --git a/app/src/main/java/io/xpipe/app/hub/comp/StoreViewState.java b/app/src/main/java/io/xpipe/app/hub/comp/StoreViewState.java index 3d14e5bad..6a759e5e2 100644 --- a/app/src/main/java/io/xpipe/app/hub/comp/StoreViewState.java +++ b/app/src/main/java/io/xpipe/app/hub/comp/StoreViewState.java @@ -12,7 +12,6 @@ import io.xpipe.app.storage.DataStoreCategory; import io.xpipe.app.storage.DataStoreEntry; import io.xpipe.app.storage.StorageListener; -import io.xpipe.app.util.ThreadHelper; import javafx.application.Platform; import javafx.beans.Observable; import javafx.beans.binding.Bindings; @@ -247,17 +246,21 @@ public class StoreViewState { .toList(); if (matchingCats.size() == 1) { var onlyMatch = matchingCats.getFirst(); - StoreCategoryWrapper matchingParent = onlyMatch; - while ((matchingParent = matchingParent.getParent()) != null) { - if (matchingParent.equals(activeCategory.getValue())) { - break; - } - } + selectCategoryIntoViewIfNeeded(onlyMatch); + } + } - if (matchingParent == null) { - activeCategory.setValue(onlyMatch); + public void selectCategoryIntoViewIfNeeded(StoreCategoryWrapper category) { + StoreCategoryWrapper matchingParent = category; + while ((matchingParent = matchingParent.getParent()) != null) { + if (matchingParent.equals(activeCategory.getValue())) { + break; } } + + if (matchingParent == null) { + activeCategory.setValue(category); + } } private void initBatchListeners() {