Skip to content

Conversation

@gadenbuie
Copy link
Member

There was a small bug in #546 that would manifest when running an app via shiny::runApp().

When the following app is run via shiny::runApp()

library(shiny)
library(bslib)

ui <- fluidPage(
  navs_bar(nav("Foo", "foo"))
)

shinyApp(ui, function(...) { })

it will currently generate an error

Error in `rlang::env_name()`:
! `env` must be an environment, not `NULL`.

due to runApp()'s use of eval(). This PR catches the case of the calling function's environment being NULL and assumes that means the function is not being called from within Shiny. With this PR, when you exit the app, the expected deprecation warnings are printed.

You can replace navs_bar() with tabsetPanel() to verify that the deprecation warnings are appropriately muffled in tabsetPanel().

library(shiny)
library(bslib)

ui <- fluidPage(
  # navs_bar(nav("Foo", "foo"))
  tabsetPanel(
    tabPanel("Foo", "foo")
  )
)

shinyApp(ui, function(...) { })

(If testing, be sure to run via shiny::runApp().)

@gadenbuie gadenbuie merged commit adf7337 into main May 16, 2023
@gadenbuie gadenbuie deleted the fix/navs-caller-fn-env branch May 16, 2023 19:59
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

Successfully merging this pull request may close these issues.

3 participants