Skip to content

Commit

Permalink
Merge branch 'main' into fix_verdepcheck
Browse files Browse the repository at this point in the history
  • Loading branch information
pawelru authored Apr 8, 2024
2 parents f870fa5 + a736303 commit 5d02a54
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 12 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Type: Package
Package: teal
Title: Exploratory Web Apps for Analyzing Clinical Trials Data
Version: 0.15.2.9020
Date: 2024-04-01
Version: 0.15.2.9021
Date: 2024-04-08
Authors@R: c(
person("Dawid", "Kaledkowski", , "[email protected]", role = c("aut", "cre"),
comment = c(ORCID = "0000-0001-9533-457X")),
Expand Down
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# teal 0.15.2.9020
# teal 0.15.2.9021

### Miscellaneous
* Filter mapping display is no longer coupled to the snapshot manager.
Expand Down
40 changes: 31 additions & 9 deletions R/TealAppDriver.R
Original file line number Diff line number Diff line change
Expand Up @@ -237,15 +237,8 @@ TealAppDriver <- R6::R6Class( # nolint: object_name.
#' @description
#' Get the active datasets that can be accessed via the filter panel of the current active teal module.
get_active_filter_vars = function() {
displayed_datasets_index <- unlist(
self$get_js(
sprintf(
"Array.from(
document.querySelectorAll(\"#%s-active-filter_active_vars_contents > span\")
).map((el) => window.getComputedStyle(el).display != \"none\");",
self$active_filters_ns()
)
)
displayed_datasets_index <- self$is_visible(
sprintf("#%s-active-filter_active_vars_contents > span", self$active_filters_ns())
)

available_datasets <- self$get_text(
Expand All @@ -257,6 +250,35 @@ TealAppDriver <- R6::R6Class( # nolint: object_name.
available_datasets[displayed_datasets_index]
},
#' @description
#' Test if `DOM` elements are visible on the page with a JavaScript call.
#' @param selector (`character(1)`) `CSS` selector to check visibility.
#' A `CSS` id will return only one element if the UI is well formed.
#' @param content_visibility_auto,opacity_property,visibility_property (`logical(1)`) See more information
#' on <https://developer.mozilla.org/en-US/docs/Web/API/Element/checkVisibility>.
#'
#' @return Logical vector with all occurrences of the selector.
is_visible = function(selector,
content_visibility_auto = FALSE,
opacity_property = FALSE,
visibility_property = FALSE) {
checkmate::assert_string(selector)
checkmate::assert_flag(content_visibility_auto)
checkmate::assert_flag(opacity_property)
checkmate::assert_flag(visibility_property)
unlist(
self$get_js(
sprintf(
"Array.from(document.querySelectorAll('%s')).map(el => el.checkVisibility({%s, %s, %s}))",
selector,
# Extra parameters
sprintf("contentVisibilityAuto: %s", tolower(content_visibility_auto)),
sprintf("opacityProperty: %s", tolower(opacity_property)),
sprintf("visibilityProperty: %s", tolower(visibility_property))
)
)
)
},
#' @description
#' Get the active filter variables from a dataset in the `teal` app.
#'
#' @param dataset_name (character) The name of the dataset to get the filter variables from.
Expand Down
30 changes: 30 additions & 0 deletions man/TealAppDriver.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 5d02a54

Please sign in to comment.