Skip to content

Session$resetBrush Does Not Work For Shiny Modules #2866

Open

Description

@loganknecht

Hello there.

Just letting you know that if you're using shiny modules to compose a Shiny app the call session$resetBrush won't work with the default input name, and you will have to compose your id by yourself.

UI Component

markerDensityPlotOutput <- function(id) {
    # --------------------------------------------------------------------------
    # REQUIRED
    ns <- NS(id)
    # --------------------------------------------------------------------------
    plot_output_to_return <- shiny::plotOutput(
        brush = ns("plot_brush"),
        outputId = ns("marker_density"),
    )
    return(plot_output_to_return)
}

Server Component

markerDensity <- function(input, output, session) {
    observeEvent(input$plot_brush, {
           # THIS DOES NOT WORK
            session$resetBrush("plot_brush")
           # THIS DOES WORK
           ns <- NS(marker_density_plot_output_module_name)
           plot_brush_namespace_id <- ns("plot_brush")
           session$resetBrush(plot_brush_namespace_id)
    })
}

What's interesting is the input$plot_brush is detected correctly, so not sure why this is a problem

Activity

  1. mjdall commented on Jun 4, 2020

    @mjdall

    Session should definitely be able to reset a brush from within a namespace.

    As a temporary fix, i've used:
    session$resetBrush(input$brush$brushId)

    Which allows you to not have to reference a brush's namespace from within the module

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions