From ce0fbbe08e63527bd5a982df9bffddffcf3d9214 Mon Sep 17 00:00:00 2001 From: nteetor Date: Tue, 21 Jan 2020 15:14:14 -0500 Subject: [PATCH] fix(listGroupInput): shift dots arg to front --- R/list-group.R | 12 ++++++------ man/listGroupInput.Rd | 10 +++++----- tests/testthat/test-list-group.R | 24 +++++++++++++++--------- 3 files changed, 26 insertions(+), 20 deletions(-) diff --git a/R/list-group.R b/R/list-group.R index 3a235663..c552cc2f 100644 --- a/R/list-group.R +++ b/R/list-group.R @@ -107,15 +107,15 @@ #' layout = "horizontal" #' ) #' -listGroupInput <- function(id, choices = NULL, values = choices, - selected = NULL, ..., layout = "vertical", +listGroupInput <- function(..., id, choices = NULL, values = choices, + selected = NULL, layout = "vertical", flush = FALSE) { assert_id() assert_choices() assert_possible(layout, c("vertical", "horizontal")) assert_possible(flush, c(TRUE, FALSE)) - tag <- dep_attach({ + with_deps({ layout <- resp_construct(layout, c("vertical", "horizontal")) classes <- resp_classes(layout, "list-group") @@ -124,7 +124,7 @@ listGroupInput <- function(id, choices = NULL, values = choices, items <- map_listitems(choices, values, selected) - tags$div( + tag <- div( class = str_collate( "yonder-list-group", "list-group", @@ -135,9 +135,9 @@ listGroupInput <- function(id, choices = NULL, values = choices, items, ... ) - }) - s3_class_add(tag, c("yonder_list_group", "yonder_input")) + s3_class_add(tag, c("yonder_list_group", "yonder_input")) + }) } #' @rdname listGroupInput diff --git a/man/listGroupInput.Rd b/man/listGroupInput.Rd index d3865f8c..8de08f32 100644 --- a/man/listGroupInput.Rd +++ b/man/listGroupInput.Rd @@ -6,11 +6,11 @@ \title{List group inputs} \usage{ listGroupInput( + ..., id, choices = NULL, values = choices, selected = NULL, - ..., layout = "vertical", flush = FALSE ) @@ -26,6 +26,10 @@ updateListGroupInput( ) } \arguments{ +\item{...}{Additional named arguments passed as HTML attributes to the +parent element or tag elements passed as child elements to the parent +element.} + \item{id}{A character string specifying the id of the reactive input.} \item{choices}{A vector of character strings or list of tag elements specifying @@ -37,10 +41,6 @@ defaults to \code{choices}.} \item{selected}{One or more of \code{values} specifying which choices are selected by default, defaults to \code{NULL}, in which case no choice is selected.} -\item{...}{Additional named arguments passed as HTML attributes to the -parent element or tag elements passed as child elements to the parent -element.} - \item{layout}{A \link{responsive} argument. One of \code{"vertical"} or \code{"horizontal"} specifying how list items are laid out, defaults to \code{"vertical"}. Note, if \code{layout} is \code{"horizontal"} and the \code{flush} argument is ignored.} diff --git a/tests/testthat/test-list-group.R b/tests/testthat/test-list-group.R index 3a582e2a..294660ea 100644 --- a/tests/testthat/test-list-group.R +++ b/tests/testthat/test-list-group.R @@ -1,21 +1,27 @@ context("list group input") test_that("id is character or null", { - expect_silent(listGroupInput("ID")) - expect_silent(listGroupInput(NULL)) + expect_silent(listGroupInput(id = "ID")) + expect_silent(listGroupInput(id = NULL)) - expect_error(listGroupInput(NA_character_)) - expect_error(listGroupInput(3030)) + expect_error(listGroupInput(id = NA_character_)) + expect_error(listGroupInput(id = 3030)) }) test_that("choices and values same length", { - expect_silent(listGroupInput("ID", c("one"))) - expect_silent(listGroupInput("ID", c("two"), c("two"))) + expect_silent(listGroupInput(id = "ID", choices = c("one"))) + expect_silent(listGroupInput( + id = "ID", choices = c("two"), values = c("two") + )) - expect_error(listGroupInput("ID", c("three"), c("three", "four"))) - expect_error(listGroupInput("ID", c("four", "five"), "four")) + expect_error(listGroupInput( + id = "ID", choices = c("three"), values = c("three", "four") + )) + expect_error(listGroupInput( + id = "ID", choices = c("four", "five"), values = "four" + )) }) test_that("has dependencies", { - expect_dependencies(listGroupInput("ID")) + expect_dependencies(listGroupInput(id = "ID")) })