Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

messageItem Hyperlink Reference Logic #377

Open
darred-py opened this issue May 28, 2024 · 0 comments
Open

messageItem Hyperlink Reference Logic #377

darred-py opened this issue May 28, 2024 · 0 comments

Comments

@darred-py
Copy link

Starting at line 12 in the function definition of messageItem, the following logic
shiny::tagList(shiny::a(class = itemCl, id = inputId, href = if (is.null(inputId)) { "#" } else { href }, ...)
returns "#" even if href is supplied as input.

If the behavior is correct, I suggest updating the function description to be more precise in what is required. Else, I believe what may have happened was a "!" was missed in the logic so that:
href = if (!is.null(inputId)) { "#" } else { href }
is the intended behavior. This would allow not having to create unused inputId variables.

Thanks!

messageItem <- function (from, message, icon = shiny::icon("user"), time = NULL, 
  href = NULL, image = NULL, color = "secondary", inputId = NULL) 
{
  tagAssert(icon, type = "i")
  if (is.null(href)) 
    href <- "#"
  if (!is.null(color)) 
    validateStatusPlus(color)
  itemCl <- "dropdown-item"
  if (!is.null(inputId)) 
    itemCl <- paste0(itemCl, " action-button")
  shiny::tagList(shiny::a(class = itemCl, id = inputId, href = if (is.null(inputId)) {
    "#"
  }
  else {
    href
  }, target = if (is.null(inputId)) {
    if (!is.null(href)) 
      "_blank"
  }, shiny::div(class = "media", if (!is.null(image)) {
    shiny::img(src = image, alt = "User Avatar", class = "img-size-50 mr-3 img-circle")
  }, shiny::tags$div(class = "media-body", shiny::tags$h3(class = "dropdown-item-title", 
    from, if (!is.null(icon)) {
      shiny::tags$span(class = paste0("float-right text-sm text-", 
        color), icon)
    }), shiny::tags$p(class = "text-sm", message), if (!is.null(time)) {
    shiny::tags$p(class = "text-sm text-muted", shiny::tags$i(class = "far fa-clock mr-1"), 
      time)
  }))), shiny::tags$div(class = "dropdown-divider"))
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant