3

The ShinyBS package provides a great and easy way to add tooltips and popovers to elements of a Shiny app. However, the length of these is sharply limited at around 40 characters. I really need to increase the number of characters allowed in these tooltips.

An example:

library(shiny)
library(shinyBS)

shinyApp(
  ui = fluidPage(
      column(5,sliderInput("n", "Short tooltip", 5, 100, 20),
                   bsTooltip("n",title="This is a short tooltip, so it works."),
                   sliderInput("n2", "Long tooltip", 5, 100, 20),
                   bsTooltip("n2",title="This is a longer tooltip, so it doesn't work."))
  ), 
  server = function(input, output) {}
)
sssheridan
  • 690
  • 1
  • 6
  • 15

1 Answers1

5

It's actually the presence of an unescaped ' in that second tooltip's title that's causing you problems, not the title's length. Typing \\' in place of each ' will fix the problem.

Try running this (or, for that matter, the example in ?bsTooltip) to see that tooltips with long titles work just fine:

library(shiny)
library(shinyBS)

shinyApp(
  ui = fluidPage(
      column(5,
             sliderInput("n", "Short tooltip", 5, 100, 20),
             bsTooltip("n",title="This is a short tooltip, so it works."),
             sliderInput("n2", "Long tooltip", 5, 100, 20),
             bsTooltip("n2",title="This is a longer tooltip, which\\'ll still work, as long as each special character is escaped with a \\\\\\\\."))
  ), 
  server = function(input, output) {}
)
Josh O'Brien
  • 159,210
  • 26
  • 366
  • 455
  • Fixed my problem! All of my longer tooltips had " or ' in them. Do you know the full list of special characters that have to be escaped? – sssheridan Apr 28 '16 at 10:28
  • 1
    Glad that worked. I don't know the full list offhand, but a quick Google search for "JavaScript special characters" gets me [this](https://msdn.microsoft.com/en-us/library/2yfce773%28v=vs.94%29.aspx), which looks like it'd be reasonably helpful. – Josh O'Brien Apr 28 '16 at 14:26