Skip to content

Commit eab4a03

Browse files
authored
Merge pull request #61 from Appsilon/60-fix-single-choice-dropdown
fix: make dropdown work with a singular choice
2 parents 4f9dc39 + fa8ab78 commit eab4a03

4 files changed

Lines changed: 9 additions & 2 deletions

File tree

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Type: Package
22
Package: reactable.extras
33
Title: Extra Features for 'reactable' Package
4-
Version: 0.2.0.9000
4+
Version: 0.2.0.9001
55
Authors@R:
66
c(
77
person("Recle", "Vibal", role = c("aut", "cre"), email = "opensource+recle@appsilon.com"),

NEWS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# reactable.extras (development)
22

33
- Fix server-side processing example.
4+
- Dropdown now work with a singular choice.
45

56
# reactable.extras 0.2.0
67

R/inputs.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ build_dropdown_extra_choices <- function(choices) {
129129
if (length(choices) == 0) {
130130
choices_js <- ""
131131
} else {
132-
choices_js <- paste0(", choices: ", rjson::toJSON(choices))
132+
choices_js <- paste0(", choices: ", rjson::toJSON(as.list(choices)))
133133
}
134134

135135
return(choices_js)

tests/testthat/test-inputs.R

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ test_that("`dropdown_extra` sets choices to blank when length is 0", {
3434
expect_equal(choices, "")
3535
})
3636

37+
test_that("`dropdown_extra` serializes a single value as an array", {
38+
choices <- build_dropdown_extra_choices("a")
39+
40+
expect_equal(choices, ', choices: ["a"]')
41+
})
42+
3743
test_that("`dropdown_extra` sets choices correctly", {
3844
choices <- build_dropdown_extra_choices(letters[1:3])
3945

0 commit comments

Comments
 (0)