Skip to content

live-search is not activated for functional subset #265

@donyunardi

Description

@donyunardi

Summary

Live search is not activated when users use a functional subset to define choices_selected or variable_selected, even though there are more than 10 choices once the function is processed.

Example Code
library(teal.modules.clinical)

ADSL <- tmc_ex_adsl
ADSL$EOSDY[1] <- NA_integer_

func_subset <- function(data){
  idx <- vapply(data, is.factor, logical(1))
  names(data)[idx]  
}

app <- init(
  data = cdisc_data(
    ADSL = ADSL,
    code = "
      ADSL <- tmc_ex_adsl
      ADSL$EOSDY[1] <- NA_integer_
    "
  ),
  modules = modules(
    tm_t_summary(
      label = "Demographic Table",
      dataname = "ADSL",
      arm_var = choices_selected(c("ARM", "ARMCD"), "ARM"),
      add_total = TRUE,
      summarize_vars = choices_selected(
        choices = variable_choices("ADSL", func_subset)
      ),
      useNA = "ifany"
    )
  )
)
if (interactive()) {
  shinyApp(app$ui, app$server)
}

Here's what it looks like:

My expectation is something like this since choices, after delayed process, has more than 10 values:

This is because value of choices is NULL when this line is executed in teal.widgets:

"live-search" = ifelse(length(choices) > 10, TRUE, FALSE)

I think the reason the value is NULL is because of this line in teal.transform:

  choices = `if`(inherits(select, "delayed_select_spec"), NULL, select$choices),

If it's delayed, then it's automatically set choices to NULL.

@kumamiao
Before we move into fixing mode, I want to first check whether the app is intended to show live search when users are using a functional subset. The way the code is written right now makes me think that the initial decision might have been to not show live search in this case. If so, should it stay that way or should we change this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions