Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unstable default value selection #8

Open
kim-freitag opened this issue Dec 20, 2024 · 1 comment
Open

Unstable default value selection #8

kim-freitag opened this issue Dec 20, 2024 · 1 comment

Comments

@kim-freitag
Copy link

Thank you for this component. I came across the following unexpected behavior while working with it:
Unless the default value is selected as last operation on the ToggleButtonGroup, it apperas to lack the primary theme on the first load.

Working

        ToggleButtonGroup<Answer> group40 = new ToggleButtonGroup<>();
        group40.setId("group40");
        group40.setItems(List.of(Answer.values()));
        group40.setItemTooltipTextGenerator(answer ->
                                                    switch (answer) {
                                                        case YES -> "Answer is yes";
                                                        case NO -> "Answer is no";
                                                        default -> throw new IllegalStateException("Unexpected value");
                                                    }
        );
        group40.setValue(Answer.YES);

Missing primary theme

        ToggleButtonGroup<Answer> group40 = new ToggleButtonGroup<>();
        group40.setId("group40");
        group40.setItems(List.of(Answer.values()));
        group40.setValue(Answer.YES);
        // adding the generator last appears to mess with the default selection
        group40.setItemTooltipTextGenerator(answer ->
                                                    switch (answer) {
                                                        case YES -> "Answer is yes";
                                                        case NO -> "Answer is no";
                                                        default -> throw new IllegalStateException("Unexpected value");
                                                    }
        );
@taefi
Copy link
Owner

taefi commented Dec 20, 2024

Thanks @kim-freitag, for creating this issue! I'll take a look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants