Skip to content

Fix CSS load when we use only fixed picks UI container#76

Merged
osenan merged 2 commits into
mainfrom
fix-css-fixed-picks@main
May 7, 2026
Merged

Fix CSS load when we use only fixed picks UI container#76
osenan merged 2 commits into
mainfrom
fix-css-fixed-picks@main

Conversation

@osenan
Copy link
Copy Markdown
Contributor

@osenan osenan commented May 7, 2026

This is fixing this issue #75

Please compare the screenshot in the issue with this branch. You can try this example:

library("teal")
devtools::load_all()

# --- Custom dummy teal module using a single fixed picks object ---

ui_dummy <- function(id, var_picks, ...) {
  ns <- shiny::NS(id)
  shiny::tagList(
    teal.widgets::standard_layout(
      output = shiny::verbatimTextOutput(ns("out")),
      encoding = shiny::tags$div(
        shiny::tags$label("Encodings", class = "text-primary"),
        shiny::tags$div(
          shiny::tags$strong("Variable"),
          teal.picks::picks_ui(id = ns("var"), picks = var_picks)
        )
      )
    )
  )
}

srv_dummy <- function(id, data, dataname, var_picks) {
  checkmate::assert_class(data, "reactive")
  shiny::moduleServer(id, function(input, output, session) {
    selectors <- teal.picks::picks_srv(
      picks = list(var = var_picks),
      data = data
    )

    merged <- teal.picks::merge_srv(
      id = "merge",
      data = data,
      selectors = selectors,
      output_name = "ANL"
    )

    output$out <- shiny::renderPrint({
      selected_var <- merged$variables()$var
      anl <- merged$data()[["ANL"]]
      cat("Selected variable:", selected_var, "\n")
      print(head(anl[[selected_var]]))
    })
  })
}

tm_dummy <- function(label, dataname,
                     var_picks = teal.picks::variables(
                       choices = "ADY",
                       selected = "ADY",
                       fixed = TRUE
                     )) {
  var_picks <- teal.picks::picks(teal.picks::datasets(dataname), var_picks)
  teal::module(
    label = label,
    datanames = dataname,
    ui = ui_dummy,
    ui_args = list(var_picks = var_picks),
    server = srv_dummy,
    server_args = list(dataname = dataname, var_picks = var_picks)
  )
}

# --- App ---

data <- teal_data() %>%
  within({
    ADTR <- teal.data::rADTR
  })

join_keys(data) <- default_cdisc_join_keys[names(data)]

app <- init(
  data = data,
  modules = modules(
    tm_dummy(
      label = "Dummy module (fixed picks)",
      dataname = "ADTR"
    )
  )
)

shinyApp(app$ui, app$server)

The fix consisted on loading the css differently. Previously, the CSS was being loaded only when we used the clickable badge dropdown. Now, if the developer does not provide a custom container, we load the css regardless of using fixed or clickable picks UI.

image

See that the styling is correct now

@osenan osenan requested a review from averissimo May 7, 2026 14:39
@osenan osenan added the core label May 7, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 7, 2026

badge

Code Coverage Summary

Filename                  Stmts    Miss  Cover    Missing
----------------------  -------  ------  -------  -------------------------------------------------------------
R/as_picks.R                140      21  85.00%   63, 167-171, 182-186, 201-207, 229-231
R/assertion.R                 5       0  100.00%
R/call_utils.R              147      22  85.03%   23-28, 65, 132-138, 259, 279-280, 283-287, 292
R/helpers.R                   9       0  100.00%
R/interaction.R              42       1  97.62%   95
R/module_merge.R            257       2  99.22%   328, 607
R/module_picks.R            315      23  92.70%   47-53, 72, 109-110, 298-300, 302-306, 429, 478, 516, 528, 536
R/picks.R                   183       1  99.45%   335
R/print.R                    36       2  94.44%   50, 58
R/resolver.R                141      15  89.36%   110-118, 284-289
R/tidyselect-helpers.R       29       0  100.00%
R/tm_merge.R                 54      54  0.00%    42-102
R/ui_containers.R            47       0  100.00%
R/zzz.R                       5       5  0.00%    3-11
TOTAL                      1410     146  89.65%

Diff against main

Filename             Stmts    Miss  Cover
-----------------  -------  ------  --------
R/module_picks.R        -3       0  -0.07%
R/ui_containers.R       +5       0  +100.00%
TOTAL                   +2       0  +0.01%

Results for commit: 2aeab9d

Minimum allowed coverage is 80%

♻️ This comment has been updated with latest results

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 7, 2026

Unit Tests Summary

  1 files   10 suites   16s ⏱️
256 tests 242 ✅ 14 💤 0 ❌
384 runs  369 ✅ 15 💤 0 ❌

Results for commit 2aeab9d.

♻️ This comment has been updated with latest results.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 7, 2026

Unit Test Performance Difference

Test Suite $Status$ Time on main $±Time$ $±Tests$ $±Skipped$ $±Failures$ $±Errors$
badge_dropdown 💀 $0.16$ $-0.16$ $-1$ $-1$ $0$ $0$
Additional test case details
Test Suite $Status$ Time on main $±Time$ Test Case
assertion 👶 $+0.02$ unnamed
badge_dropdown 💀 $0.16$ $-0.16$ shinytest2_badge_dropdown_is_visible_when_clicking_on_it_multiple_times

Results for commit 829ce00

♻️ This comment has been updated with latest results.

@averissimo averissimo self-assigned this May 7, 2026
Copy link
Copy Markdown
Contributor

@averissimo averissimo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like the move of the CSS tag, please see comment below

Comment thread R/module_picks.R Outdated
Comment thread R/ui_containers.R Outdated
Copy link
Copy Markdown
Contributor

@averissimo averissimo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome!

@osenan osenan merged commit 162c5d9 into main May 7, 2026
24 of 25 checks passed
@osenan osenan deleted the fix-css-fixed-picks@main branch May 7, 2026 19:33
@github-actions github-actions Bot locked and limited conversation to collaborators May 7, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants