@@ -274,13 +274,16 @@ bs4_navbar_links_tags <- function(links, depth = 0L, side = "left") {
274
274
return (
275
275
htmltools :: tags $ li(
276
276
class = menu_class ,
277
- htmltools :: tags $ a(
278
- href = " #" , class = " nav-link dropdown-toggle" ,
279
- `data-bs-toggle` = " dropdown" , role = " button" ,
280
- `aria-expanded` = " false" , `aria-haspopup` = " true" ,
277
+ htmltools :: tags $ button(
278
+ href = " #" ,
279
+ class = " nav-link dropdown-toggle" ,
280
+ `data-bs-toggle` = " dropdown" ,
281
+ type = " button" ,
282
+ `aria-expanded` = " false" ,
283
+ `aria-haspopup` = " true" ,
281
284
link_text ,
282
285
id = paste0(" dropdown-" , make_slug(link_text )),
283
- " aria-label" = x $ `aria-label` %|| % NULL
286
+ " aria-label" = x $ `aria-label` %|| % NULL
284
287
),
285
288
htmltools :: tags $ div(
286
289
class = dropdown_class ,
@@ -336,24 +339,21 @@ bs4_navbar_links_tags <- function(links, depth = 0L, side = "left") {
336
339
337
340
tags <- purrr :: map2(links , seq_along(links ), tackle_link , is_submenu = is_submenu , depth = depth )
338
341
htmltools :: tagList(tags )
339
-
340
342
}
341
343
342
344
bs4_navbar_link_text <- function (x , ... ) {
343
-
344
345
if (! is.null(x $ icon )) {
345
- # find the iconset
346
- split <- strsplit(x $ icon , " -" )
347
- if (length(split [[1 ]]) > 1 ) {
348
- iconset <- split [[1 ]][[1 ]]
349
- }
350
- else {
351
- iconset <- " "
352
- }
353
- htmltools :: tagList(htmltools :: tags $ span(class = paste(iconset , x $ icon )), " " , x $ text , ... )
354
- }
355
- else
346
+ # Find the icon set
347
+ classes <- strsplit(x $ icon , " " )[[1 ]]
348
+ icon_classes <- classes [grepl(" -" , classes )]
349
+ iconset <- purrr :: map_chr(strsplit(icon_classes , " -" ), 1 )
350
+ class <- paste0(unique(c(iconset , classes )), collapse = " " )
351
+
352
+ text <- paste0(if (! is.null(x $ text )) " " , x $ text )
353
+ htmltools :: tagList(htmltools :: tags $ span(class = class ), text , ... )
354
+ } else {
356
355
htmltools :: tagList(x $ text , ... )
356
+ }
357
357
}
358
358
359
359
# Testing helpers ---------------------------------------------------------
0 commit comments