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

Attributes renderUI has a weird behavior #116

Closed
earnaud opened this issue Nov 6, 2020 · 2 comments
Closed

Attributes renderUI has a weird behavior #116

earnaud opened this issue Nov 6, 2020 · 2 comments

Comments

@earnaud
Copy link
Owner

earnaud commented Nov 6, 2020

Running the app returns a valid Attribute module for the UI part with such HTML:

<textarea id="fill-Attributes-nitrogen.csv-date-attributeDefinition" class="form-control shinyjs-resettable" data-shinyjs-resettable-id="fill-Attributes-nitrogen.csv-date-attributeDefinition" data-shinyjs-resettable-type="TextArea" data-shinyjs-resettable-value="Description for date">Description for date</textarea>

(above, the input for describing a "date" attribute)

BUT:

when asking for names(input), this is empty. No idea why, still investigating.

This topic is dedicated to help this issue to be solved if met by anyone else furtherly in the shinyverse.

@earnaud
Copy link
Owner Author

earnaud commented Nov 9, 2020

Here is a reproducible example. The bug seems to occur from the module server part initiating without UI being set. Therefore, listeners listen to NULL.

library(shiny)

test_UI <- function(id) {
  ns <- NS(id)
  tagList(
    textInput("test", "test")
  )
}

test_server <- function(id, rv) {
  moduleServer(id, function(input, output, session) {
    observeEvent(input$test, {
      rv$text <- input$test
    })
  })
}

ui <- fluidPage(
  actionButton("dev", "dev"),
  uiOutput("test")
)

server <- function(input, output, session) {
  rv <- reactiveValues(
    text = ""
  )
  
  output$test <- renderUI({
    test_UI("outer")
  })
  
  test_server("outer")
  
  observeEvent(input$dev, {
    browser()
  })
}

shinyApp(ui, server)

EDIT

Well, no.

@earnaud
Copy link
Owner Author

earnaud commented Nov 9, 2020

** Solved **

The JS console (right-click > inspect element > errors) showed that an ID was duplicated while rendering the attributes edit area. Thus, this one did not render anything at all.

Morale: in absence of errors, first check these logs.

@earnaud earnaud closed this as completed Nov 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant