Skip to content

ui.input_task_button doesn't work inside module #1107

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

Closed
pstorozenko opened this issue Feb 5, 2024 · 2 comments · Fixed by #1108
Closed

ui.input_task_button doesn't work inside module #1107

pstorozenko opened this issue Feb 5, 2024 · 2 comments · Fixed by #1108

Comments

@pstorozenko
Copy link

pstorozenko commented Feb 5, 2024

It seems to me that the freshly introduced input_task_button doesn't work with shiny modules.

The following code:

from shiny import App, module, reactive, render, ui


@module.ui
def button_ui():
    return ui.p(
        # ui.input_task_button("btn", label="Click me!"),
        ui.input_action_button("btn", label="Click me!"),
        ui.output_text("text_counter"),
    )


@module.server
def button_server(input, output, session):
    counter = reactive.Value(0)
    @render.text
    def text_counter():
        return f"Button clicked {counter()} times"
    
    @reactive.effect
    @reactive.event(input.btn)
    def increment_counter():
        counter.set(counter() + 1)


app_ui = ui.page_fluid(
    button_ui("button")
)


def server(input, output, session):
    button_server("button")


app = App(app_ui, server)

Work with ui.input_action_button it works, but with ui.input_task_button I get the following message in the terminal:

INFO:     connection open
_send_error_response: The string 'button-btn' is not a valid id; only letters, numbers, and underscore are permitted
INFO:     connection closed

Am I write, or the input_task_button should be used in a different way?


shiny == 0.7.0, python == 3.10.13

@jcheng5
Copy link
Collaborator

jcheng5 commented Feb 5, 2024

Ouch, it is a bug. I'm fixing it right now. Thanks for the report and the reprex!

@jcheng5
Copy link
Collaborator

jcheng5 commented Feb 5, 2024

This is fixed on the main branch now. You can install it with

pip install --upgrade git+https://github.com/posit-dev/py-shiny.git

Thanks again!

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

Successfully merging a pull request may close this issue.

2 participants