Skip to content

live-search is not activated for functional subset #265

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

Open
donyunardi opened this issue Sep 6, 2024 · 1 comment
Open

live-search is not activated for functional subset #265

donyunardi opened this issue Sep 6, 2024 · 1 comment
Labels

Comments

@donyunardi
Copy link
Contributor

donyunardi commented Sep 6, 2024

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?

@donyunardi donyunardi added the core label Sep 6, 2024
@kumamiao
Copy link

kumamiao commented Sep 9, 2024

I'm not entirely sure why 10 here, but I assume the intention may be if there are less than 10, all choices are visible and the need for search may low?

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

Discussed with @donyunardi, I'm okay with either setting it to TRUE so that we're consistent and transparent (otherwise user would not know what triggered the live search); or we add an additional argument in teal.widget (I personally prefer TRUE as default) that can be passed by app developer when setting the choices_selected or variable_selected. Would prefer to not touch teal.transform for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants