Skip to content

Commit

Permalink
add data-title attr as step_title of first step
Browse files Browse the repository at this point in the history
  • Loading branch information
mauromiguelm committed Mar 5, 2024
1 parent f1d91ad commit c2a0e4a
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions R/wizard.R
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,12 @@ wizard <- function(
)

steps <- list(...)

if (length(steps) > 0) {
# get data-title with htmltools::htmlAttributes
first_step_title <- htmltools::tagGetAttribute(steps[[1]], "data-title")
first_step_title <- ifelse(is.null(first_step_title), "Step 0", first_step_title)
}

if (length(steps) > 0 && flex) {
# iterate over steps and apply flex
Expand Down Expand Up @@ -134,6 +140,8 @@ wizard <- function(
id = wiz_id,
"data-configuration" = jsonlite::toJSON(options, auto_unbox = TRUE),
"data-active-step" = "0",
# set data title to the title of the first step
"data-title" = if (length(steps) > 0) steps[[1]]$`data-title` else NULL,
content,
wizard_dependencies()
) # end of wizard
Expand Down

0 comments on commit c2a0e4a

Please sign in to comment.