Skip to content

[Bug]: Inconsistent population of ui.input_selectize() by update_selectize() #1990

Open
@hwismer

Description

@hwismer

Component

UI (ui.*)

Severity

P1 - High (major feature broken)

Shiny Version

1.2.1

Python Version

3.12.2

Minimal Reproducible Example

from shiny import App, render, ui

humu_tabs_mapped_to_gene_inputs = {"Mouse Gene Expression Box Plots" : [["humu_gex_box_gene", "Mouse"]],
                                   "Mouse Gene Expression Dotplots" : [["humu_gex_dot_gene", "Mouse"]],
                                   "HuMu Gene Expression Comparison" : [["humu_box_comp_human_genes", "Human"],["humu_box_comp_mu_genes", "Mouse"]],
}

app = app_ui = ui.page_fluid(
ui.nav_panel("Mouse Gene Expression Dotplots",
                    ui.layout_sidebar(
                        ui.sidebar(
                            ui.input_selectize("humu_gex_dot_gene", "Choose Genes to plot:", [], multiple=True),
                            ui.input_selectize("humu_gex_dot_groupby", "Group By:", hsh.categoricals_opts, selected="---"),
                            ui.input_selectize("humu_gex_dot_groups", "Subset Groupby Categories:", [], multiple=True),
                            ui.input_selectize("humu_gex_dot_splitby", "Split By:", ["---"] + hsh.categoricals_opts, selected="---"),
                            ui.input_selectize('humu_gex_dot_splits', "Subset Splitby Categories:", [], multiple=True),
                            ui.input_switch("humu_gex_dot_swap", "Swap Axes"),
                            ui.input_action_button("humu_gex_dot_run", "RUN"),
                            bg=panel_color
                        ),
                    ui.card(ui.output_plot("humu_plot_gex_dotplot"), min_height="750px", full_screen=True)
                    )       
                ),
)

def server(input, output, session):
@reactive.effect
    def populate_gene_selections():
        current_tab = input.humu_top_nav()
        if current_tab not in humu_tabs_visited:
            humu_tabs_visited.append(current_tab)
            if current_tab in humu_tabs_mapped_to_gene_inputs:
                for id, category in humu_tabs_mapped_to_gene_inputs[current_tab]:
                    if category == "Mouse":
                        ui.update_selectize(
                            id,
                            choices=hsh.genes,
                            selected=[],
                            server=True,
                        )
                    else:
                        ui.update_selectize(
                            id,
                            choices=qsh.genes,
                            selected=[],
                            server=True,
                        )

Behavior

I have multiple input_selectize dropdowns that take a large number of options. To avoid long startup times for the app I initialize them as empty at first and then when the user visits a tab, the input_selectize in that tab is filled in on the server side.

However, with my hosted shiny app on shinyproxy, often random input_selectizes fail to update or display options. This isn't strictly reproducible across sessions and sometimes when the app is reloaded the input_selectize() that was broken on during a previous session works and a new input_selectize doesn't work. This doesn't happen when I run my app locally but seems to be specific to shinyproxy, but not sure how to get around this.

Error Messages (if any)

Environment

OS: Ubuntu 22.02
Browser: Firefox, Chrome
Dependencies: Shiny proxy

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions