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

Setting a select components value seems to have broken in v0.12.6 onwards #1079

Closed
oekekezie opened this issue Nov 1, 2024 · 2 comments
Closed
Labels
bug Something isn't working

Comments

@oekekezie
Copy link

oekekezie commented Nov 1, 2024

I'm using a select component to allow the user to select the dose for a given time of day. Each time period in the dose schedule is initialized to zero by default. Each select component is restricted to a range of possible doses and I include zero as the first option so that the user can specify that there is no dose during a given time period. I noticed that my approach works as expected in v0.12.5 but stopped working in v0.12.6 and v0.12.7. It seems like setting the value broke during these releases (i.e., the select component is blank)?

with me.box(
        key=f"current_dose_schedule_box", 
        style=me.Style(display="flex", flex_basis="auto", flex_wrap="wrap", gap="16px")):
        for i, time in enumerate(TIME_PERIODS_FOR_DOSE_SCHEDULE):
            me.select(
                key=f"dose_select_{state.reset_counter_dose_schedule}_{time.lower()}",
                options=[me.SelectOption(label=("No dose for this period" if dose == 0.0 else f"{format_float(dose)} mg"), value=format_float(dose)) for dose in [0.0] + filtered_dose_values],
                label=time,
                on_selection_change=update_dose_schedule,
                value="0.0", # set to zero by default on server side
                disabled=not bool(state.generic_name) or not bool(state.total_daily_dose) or  is_cds_section_visible(), # disabled if a benzodiazepine or whether to allow combinations has not been chosen and CDS section is not visible
                style=error_style if not state.total_daily_dose == 0 and not is_dose_schedule_valid() else me.Style()
            )

According to the documentation, it seems like placeholder could be an alternative for my use case? However, it's never worked in my experience which I why I started using this workaround of setting the value on the server side and being careful about triggering re-renderings.

I hope this makes and please feel free to let me know if you need any additional information to see if this is a bug or if I'm missing something. Thanks and great work on the project overall--keep it up!! :)

@oekekezie oekekezie added the bug Something isn't working label Nov 1, 2024
@richard-to
Copy link
Collaborator

Thanks for reporting the bug. We have a fix for this bug, but we haven't a cut a new release for it yet. See #1071

@richard-to
Copy link
Collaborator

We just pushed 12.8, so I believe this should be fixed now. Let us if it's still broken. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants