Closed ColinFay closed 2 years ago
+1 for this issue. Any current ideas for a workaround?
I experienced the same issue and my workaround has been as follows:
MyShinyBS.js
with` all the JS code from shinyBSSource the file in the UI:
fluidPage( tags$head(tags$script(src = "www/MyShinyBS.js")),
titlePanel("TITLE"),
....
Hey all,
The workarounds so far are :
{shinyBS}
as a Depends
so that it is attached to the search path: usethis::use_package("shinyBS", "depends")
golem_add_external_resources <- function() {
add_resource_path(
"www", app_sys("app/www")
)
add_resource_path(
"sbs", system.file("www", package = "shinyBS")
)
tags$head(
favicon(),
bundle_resources(
path = app_sys("app/www"),
app_title = "xyz"
)
# Add here other external resources
# for example, you can add shinyalert::useShinyalert()
)
}
So, the issue doesn't come from {golem}
itself but from the way {shinyBS}
attach its dependency.
https://github.com/ebailey78/shinyBS/blob/shinyBS3/R/misc.R#L1
Because of the way the dependencies are bundled, it's only available in case the package is loaded, not attached.
I'll write the {shinyBS}
team and see how this can be worked out.
Open issue on {shinyBS}
about this issue, which is due to how the package attaches its external resources.
https://github.com/ebailey78/shinyBS/issues/138
I'm putting this issue on hold for now.
In case this helps someone.
The workarounds above didn't work for me. Shiny includes Bootstrap tooltips so I ended up writing a JS function. It's something like this (can't share it exactly):
addTooltip = function(id, options) {
setTimeout(
function() {
$("#" + id).tooltip(options)
}, 1000
)
}
The setTimeout()
may or may not be needed in all cases. I added it because the function was being called too soon, before the element existed, so the tootlip didn't show.
Hey folks,
I'll close this issue for now, I don't think it's a {golem}
issue but a {shinyBS}
one — there has been an issue since 2018 (!!) to correct this https://github.com/ebailey78/shinyBS/issues/100 and a PR since 2019 https://github.com/ebailey78/shinyBS/pull/109 that corrects the issue.
There hasn't been any activity on the package since 2016 — https://github.com/ebailey78/shinyBS/commits/shinyBS3 and the last CRAN version is from 2015, so my answer would be to move to another package that is maintained and more modern.
For a tooltip, I've been using https://atomiks.github.io/tippyjs/ in several apps, I'd suggest using this one.
Just putting this here: {golem} works fine with {shinyBS} with adding it to the Depends
. The issue, as it turns out, is that jQuery > 4.1 uses the 'dispose'
method instead of 'destroy'
(https://stackoverflow.com/questions/51960211/error-no-method-named-destroy-for-popover-bootstrap).
I fixed this in my fork and the tooltips seem to work: https://github.com/psolymos/shinyBS/commit/86c427aed776fc6d5c4efcee0112e4c22c81a95e
If I create a new golem and use :
as
app_ui
, the browser returns a series of errors:preventing
{shinyBS}
from working.The very same code works in an app.R file (restart session between test to clear cache):