title: Plotly Heatmap & Scatter Linked in Shiny Not Working in a Module
body: <p>Following the example at: <a href="https://plot.ly/r/shinyapp-linked-click/" rel="nofollow">https://plot.ly/r/shinyapp-linked-click/</a> I was able to in a blank shiny project get this working (correlation matrix linked to a scatter graph). However, when I do the same in a shiny module the event_data based click action doesnt seem to work (the scatter remains blank no mater what happens, seems like the click is not connecting).</p>
  
  <p>My reproducible example is below, any ideas or solutions would be much appreciated.</p>
  
  <pre><code>library(plotly)
  
  #### Define Modules ####
  correlation_matrix_shinyUI &lt;- function(id) {
    ns &lt;- NS(id)
  
    mainPanel(
      plotlyOutput(ns("corr_matrix"), height = '650px'),
      plotlyOutput(ns("scatterplot"), height = '550px')
    )
  }
  
  correlation_matrix_shiny &lt;- function(input, output, session) {
  
    data_df &lt;- reactive({
      mtcars
    })
  
    corr_data &lt;- reactive({
      if (is.null(data_df()))
        return()
  
      corr_data &lt;- cor(data_df())
      diag(corr_data) &lt;- NA
      corr_data &lt;- round(corr_data, 4)
      corr_data
    })
  
    corr_names &lt;- reactive({
      if (is.null(data_df()))
        return()
  
      corr_names &lt;- colnames(data_df())
      corr_names
    })
  
    output$corr_matrix &lt;- renderPlotly({
      if (is.null(corr_names()))
        return()
      if (is.null(corr_data()))
        return()
  
  
      g &lt;- plot_ly(x = corr_names(), y = corr_names(), z = corr_data(), 
        key = corr_data(), type = "heatmap", source = "CORR_MATRIX", zmax = 1, zmin = -1)
      g
    })
  
    output$scatterplot &lt;- renderPlotly({
      if (is.null(data_df()))
        return()
  
      data_use &lt;- data_df()
  
      s &lt;- event_data("plotly_click", source = "CORR_MATRIX")
  
      if (length(s)) {
        vars &lt;- c(s[["x"]], s[["y"]])
        d &lt;- setNames(data_use[vars], c("x", "y"))
        yhat &lt;- fitted(lm(y ~ x, data = d))
        plot_ly(d, x = x, y = y, mode = "markers") %&gt;%
          plotly::add_trace(x = x, y = yhat, mode = "lines") %&gt;%
          plotly::layout(xaxis = list(title = s[["x"]]), 
            yaxis = list(title = s[["y"]]), 
            showlegend = FALSE)
      } else {
        plot_ly()
      }
    })
  
  }
  ############ End Module Definition ######
  
  ui &lt;- fluidPage(
    sidebarLayout(
      sidebarPanel(
      ),
      correlation_matrix_shinyUI(id = "cor_module")
    )
  )
  
  server &lt;- function(input, output, session) {
    callModule(correlation_matrix_shiny, id = "cor_module")
  }
  
  shinyApp(ui = ui, server = server)
  </code></pre>