Git Product home page Git Product logo

Comments (2)

gadenbuie avatar gadenbuie commented on May 31, 2024

Hi @Roleren, thanks for the bug report!

One important detail: this only happens when server = TRUE. In this case, the full set of choices are kept back on the server because they could be potentially large and are only sent to the client app when requested. If you completely change the available choices, the client won't know that the current (about to be old) values are no longer valid, so it keeps those values as options.

We can do slightly better than the current situation when selected is provided. I've just added a bit of code in #3967 that will clear the current value of the select input before performing the choices update when selected is provided.

Here are two other options to get around this issue with released shiny:

  1. Use fully client-side selectize inputs, i.e. server = FALSE.

  2. Manually clear the selection before updating the choices and current value, but having an observeEvent() that first clears the selection:

    choices <- reactive({
      if (input$selectID == "Numeric") {
        as.character(seq(5))
      } else {
        LETTERS[1:5]
      }
    })
    
    observeEvent(choices(), {
      # Clear the selection before updating choices
      updateSelectizeInput(
        inputId = "library",
        selected = NULL,
        server = TRUE
      )
    })
    
    observeEvent(choices(), {
      updateSelectizeInput(
        inputId = "library",
        choices = choices(),
        selected = choices()[1],
        server = TRUE
      )
    })

from shiny.

Roleren avatar Roleren commented on May 31, 2024

Thanks, this should solve the issue for now. As far as I understand, the old value is still kept if selected is not specified ?

from shiny.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.