Skip to content

Commit

Permalink
Fixes popup dialog that keeps appearing when variable is changed on `…
Browse files Browse the repository at this point in the history
…tm_outliers` (#693)

# Pull Request

Fixes #648

### Changes description

- Prevents rendering the `DT::dataTableOutput` output tag multiple times
(not the data table itself)
- I believe when the re-rendering occurs, it tries to display the
previous columns
- Given that the data changed when variable is selected, previously
available column is not found in the data

### For the reviewer

- Code to replicate the problem _(and test the solution)_ can be found
on the original issue
  • Loading branch information
averissimo authored Feb 28, 2024
1 parent 4faa505 commit ff008a3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
### Bug fixes

* Outlier labels no longer appear out of bounds in `tm_a_regression`.
* Fixed a bug in `tm_outliers` when changing the selected variable would cause a popup.

### Miscellaneous

Expand Down
8 changes: 5 additions & 3 deletions R/tm_outliers.R
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,8 @@ ui_outliers <- function(id, ...) {
)
),
br(), hr(),
uiOutput(ns("table_ui_wrap"))
uiOutput(ns("table_ui_wrap")),
DT::dataTableOutput(ns("table_ui"))
),
encoding = div(
### Reporter
Expand Down Expand Up @@ -1046,12 +1047,14 @@ srv_outliers <- function(id, data, reporter, filter_panel_api, outlier_var,
expr = {
tab <- input$tabs
req(tab) # tab is NULL upon app launch, hence will crash without this statement
shiny::req(iv_r()$is_valid()) # Same validation as output$table_ui_wrap
outlier_var <- as.vector(merged$anl_input_r()$columns_source$outlier_var)
categorical_var <- as.vector(merged$anl_input_r()$columns_source$categorical_var)

ANL_OUTLIER <- common_code_q()[["ANL_OUTLIER"]] # nolint: object_name.
ANL_OUTLIER_EXTENDED <- common_code_q()[["ANL_OUTLIER_EXTENDED"]] # nolint: object_name.
ANL <- common_code_q()[["ANL"]] # nolint: object_name.

plot_brush <- if (tab == "Boxplot") {
boxplot_r()
box_pws$brush()
Expand Down Expand Up @@ -1183,8 +1186,7 @@ srv_outliers <- function(id, data, reporter, filter_panel_api, outlier_var,
multiple = TRUE
),
h4("Outlier Table"),
teal.widgets::get_dt_rows(session$ns("table_ui"), session$ns("table_ui_rows")),
DT::dataTableOutput(session$ns("table_ui"))
teal.widgets::get_dt_rows(session$ns("table_ui"), session$ns("table_ui_rows"))
)
})

Expand Down

0 comments on commit ff008a3

Please sign in to comment.