diff --git a/app/src/main/java/io/xpipe/app/fxcomps/impl/DataStoreChoiceComp.java b/app/src/main/java/io/xpipe/app/fxcomps/impl/DataStoreChoiceComp.java index a26cf0e4..5334b23b 100644 --- a/app/src/main/java/io/xpipe/app/fxcomps/impl/DataStoreChoiceComp.java +++ b/app/src/main/java/io/xpipe/app/fxcomps/impl/DataStoreChoiceComp.java @@ -13,7 +13,6 @@ import io.xpipe.app.storage.DataStoreEntryRef; import io.xpipe.app.util.DataStoreCategoryChoiceComp; import io.xpipe.core.store.DataStore; import io.xpipe.core.store.ShellStore; -import javafx.application.Platform; import javafx.beans.binding.Bindings; import javafx.beans.property.Property; import javafx.beans.property.SimpleBooleanProperty; @@ -106,18 +105,7 @@ public class DataStoreChoiceComp extends SimpleComp { selectedCategory).styleClass(Styles.LEFT_PILL); var filter = new FilterComp(filterText) .styleClass(Styles.CENTER_PILL) - .hgrow() - .apply(struc -> { - popover.setOnShowing(event -> { - Platform.runLater(() -> { - Platform.runLater(() -> { - Platform.runLater(() -> { - struc.getText().requestFocus(); - }); - }); - }); - }); - }); + .hgrow(); var addButton = Comp.of(() -> { MenuButton m = new MenuButton(null, new FontIcon("mdi2p-plus-box-outline")); @@ -132,6 +120,15 @@ public class DataStoreChoiceComp extends SimpleComp { var top = new HorizontalComp(List.of(category, filter.hgrow(), addButton)) .styleClass("top") .apply(struc -> struc.get().setFillHeight(true)) + .apply(struc -> { + // Ugly solution to focus the text field + // Somehow this does not work through the normal on shown listeners + struc.get().getChildren().get(0).focusedProperty().addListener((observable, oldValue, newValue) -> { + if (newValue) { + ((StackPane) struc.get().getChildren().get(1)).getChildren().get(1).requestFocus(); + } + }); + }) .createStructure().get(); var r = section.vgrow().createRegion(); var content = new VBox(top, r); @@ -146,12 +143,6 @@ public class DataStoreChoiceComp extends SimpleComp { popover.setHeaderAlwaysVisible(true); popover.setDetachable(true); popover.setTitle(AppI18n.get("selectConnection")); - popover.setOnShowing(event -> { - Platform.runLater(() -> { - ((StackPane) top.getChildren().get(1)).getChildren().get(1).requestFocus(); - }); - event.consume(); - }); AppFont.small(popover.getContentNode()); }