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

Request: allow deleting an input that was removed using `removeUI()` #2374

Open
daattali opened this issue Apr 9, 2019 · 2 comments

Comments

@daattali
Copy link
Contributor

commented Apr 9, 2019

Currently, when an input is removed using removeUI(), its UI is deleted from the DOM but the input still lives from the server's perspective. It would be great if it was possible to clear that input completely.

Personal opinion: I would want this to be the default behaviour, because an input that does not exist on the page should not exist in the server - it's a bit of a logical discrepancy - but that breaking change might cause a lot of trouble so perhaps adding a parameter to removeUI() to do this would be helpful.

@daattali daattali changed the title Request: allow deleting an input that as removed using `removeUI()` Request: allow deleting an input that was removed using `removeUI()` Apr 22, 2019

@daattali

This comment has been minimized.

Copy link
Contributor Author

commented Apr 22, 2019

For anyone looking for a workaround until this gets implemented, my solution meanwhile it to set the value of any removed inputs to NULL using javascript, with Shiny.onInputChange("input", 'null')

@ColinFay

This comment has been minimized.

Copy link

commented Aug 29, 2019

Here's a reprex of this issue:

library(shiny)
ui <- fluidPage(
  actionButton("rmv", "Remove UI"),
  textInput("txt", "This is no longer useful", "plop")
)

# Server logic
server <- function(input, output, session) {
  observeEvent(input$rmv, {
    removeUI(
      selector = "#txt"
    )
  })
  observe({
    invalidateLater(1000)
    print(input$txt)
  })
}

shinyApp(ui, server)

I definitely second the idea of removing the value from the input list if the input is not there anymore.

The removeUI() function which can remove any part of the UI has to be kept, but there could be a removeInput() function, to be more specific to target the inputs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.