-
-
Notifications
You must be signed in to change notification settings - Fork 15
Don't update distribution params labels when variable is deselected in tm_g_distribution
#891
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
Conversation
tm_g_distributiontm_g_distribution
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Fixes an issue where distribution parameters were being reset unintentionally when switching variables in the tm_g_distribution module.
- Tracks manual parameter edits and previous selections with reactive values
- Updates the main observer to only recalculate parameters when truly needed
- Adds separate observers for manual edits and reset logic to manage the manual‐set flag
Comments suppressed due to low confidence (3)
R/tm_g_distribution.R:572
- [nitpick] The variable name
prev_t_distis somewhat ambiguous. Consider renaming it toprev_dist_type(and similarlyprev_variabletoprev_selected_variable) to make their purposes more explicit.
params_manually_set <- reactiveVal(FALSE)
R/tm_g_distribution.R:572
- Adding a brief comment above the
params_manually_set,prev_t_dist, andprev_variabledeclarations explaining their roles would improve readability and maintainability.
params_manually_set <- reactiveVal(FALSE)
R/tm_g_distribution.R:586
- The new conditional logic for recalculating distribution parameters based on
params_manually_setand previous values should be covered by unit or integration tests to verify that manual edits are preserved and reset behavior works correctly.
observeEvent(
Unit Tests Summary 1 files 22 suites 1s ⏱️ Results for commit 49eda1a. ♻️ This comment has been updated with latest results. |
Code Coverage SummaryDiff against mainResults for commit: 49eda1a Minimum allowed coverage is ♻️ This comment has been updated with latest results |
donyunardi
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Originally, issue arises when user deselect the "Variable" selection. This triggers the label being resetted to param1 and param2, even though distribution is selected, in this case "normal".

When I use main version, I can't deselect the "Variable" selection as it always select a variable.

Then only way to test this PR by setting the select_spect(selected = NULL) for the dist_var argument. However, I still see the same behavior where the labels are still showing 'param1' and 'param2', even though the distribution was selected.

Example code with `selected = NULL`
data <- teal_data()
data <- within(data, {
ADSL <- teal.data::rADSL
})
join_keys(data) <- default_cdisc_join_keys[names(data)]
#'
vars1 <- choices_selected(
variable_choices(data[["ADSL"]], c("ARM", "COUNTRY", "SEX")),
selected = NULL
)
#'
app <- init(
data = data,
modules = modules(
tm_g_distribution(
dist_var = data_extract_spec(
dataname = "ADSL",
select = select_spec(
choices = variable_choices(data[["ADSL"]], c("AGE", "BMRKR1")),
selected = NULL,
multiple = FALSE,
fixed = FALSE
)
),
strata_var = data_extract_spec(
dataname = "ADSL",
filter = filter_spec(
vars = vars1,
multiple = TRUE
)
),
group_var = data_extract_spec(
dataname = "ADSL",
filter = filter_spec(
vars = vars1,
multiple = TRUE
)
)
)
)
)
if (interactive()) {
shinyApp(app$ui, app$server)
}tm_g_distributiontm_g_distribution
|
Ah sorry @donyunardi I though it's params values, but it actually params labels : )
|
Co-authored-by: Dony Unardi <[email protected]> Signed-off-by: Marcin <[email protected]>

Fixes #510