mkpaz / atlantafx

Modern JavaFX CSS theme collection with additional controls.
https://mkpaz.github.io/atlantafx
MIT License
791 stars 64 forks source link

ComboBox items are shown in wrong position when they are above ComboBox #101

Closed PavelTurk closed 1 month ago

PavelTurk commented 3 months ago

Run the following code:

public class JavaFxTest7 extends Application {

    @Override
    public void start(Stage stage) {
        Application.setUserAgentStylesheet(new Dracula().getUserAgentStylesheet());
        var items = FXCollections.observableArrayList(List.of("a", "b"));
        var combobox = new ComboBox<String>();
        combobox.setItems(items);

        var vBox = new VBox(combobox);
        vBox.setStyle("-fx-font-size: 15");
        vBox.setAlignment(Pos.BOTTOM_LEFT);

        Scene scene = new Scene(vBox, 600, 200);
        stage.setScene(scene);
        stage.show();
        stage.setMaximized(true);
    }

    public static void main(String[] args) {
        launch();
    }
}

And you will get this result:

Peek 2024-05-23 12-42

As you see when you click it the fist time, then there is a space between the comboBox and items. The size of this space depends on the font size. At the same time, when you click the second time, then there is no such space.

When I use pure JavaFX (without atlantafx), then everything is OK:

Peek 2024-05-23 12-41

mkpaz commented 1 month ago

It's a JavaFX bug. If it was AtlantaFX, the popup position will be wrong every time you open it.

/* this reproduces same behavior with Modena*/
.combo-box-popup .list-cell {
    -fx-padding: 0 10 0 10;
}
PavelTurk commented 3 weeks ago

If someone has the same problem see the issue I opened - https://bugs.openjdk.org/browse/JDK-8338145