Skip to content

Commit 32f5248

Browse files
authored
Suppress c.teal_card warning when joining teal_report objects (#455)
# Pull Request <!--- Replace `#nnn` with your issue link for reference. --> Fixes warning popping up on modules using `c.teal_card` indirectly ```r pkgload::load_all("/home/averissimo/work/roche🟦/packages📦/teal.reporter") q1 <- teal.reporter::teal_report() |> within(1+1) q2 <- within(q1, 2+2) q3 <- within(q1, 3+3) c(q2, q3) #> Warning message: #> Appended `teal_card` doesn't remove some of the elements from previous `teal_card`. #> #> ✅︎ code verified #> <environment: 0x5b5d075c6b10> 🔒 #> Parent: <environment: package:teal.reporter> ``` ### Changes Description - Adds class to warning condition - Allows developers to suppress it explicitly, without hiding other warnings - Warning should not be presented when merging `teal_report` objects - Makes it look as there is something wrong with the operation and on teal apps (such as `tm_g_distribution`)
1 parent a24ce75 commit 32f5248

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

NEWS.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# teal.reporter 0.6.0.9001
22

3+
### Miscellaneous
4+
5+
* Prevents warning message when joining two `teal_card` objects that have items with the same id (#455).
6+
37
# teal.reporter 0.6.0
48

59
### New features

R/teal_card.R

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,11 @@ c.teal_card <- function(...) {
162162
v
163163
} else {
164164
warning(
165-
"Appended `teal_card` doesn't remove some of the elements from previous `teal_card`.\n",
166-
"Restoring original content and adding only new items to the end of the card."
165+
warningCondition(
166+
"Appended `teal_card` doesn't remove some of the elements from previous `teal_card`.\n",
167+
"Restoring original content and adding only new items to the end of the card.",
168+
class = "teal_card_append"
169+
)
167170
)
168171
utils::modifyList(u, v)
169172
}

R/teal_report-c.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ c.teal_report <- function(...) {
1010
result <- NextMethod()
1111
l <- Filter(function(x) inherits(x, "teal_report"), list(...))
1212
if (length(l) > 1) {
13-
teal_card(result) <- do.call(c, lapply(l, teal_card))
13+
teal_card(result) <- suppressWarnings(do.call(c, lapply(l, teal_card)), classes = "teal_card_append")
1414
}
1515
result
1616
}

0 commit comments

Comments
 (0)