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

Restore previous shiny theme when run() exits #2160

Merged
merged 2 commits into from
Jun 4, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions R/shiny.R
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ run <- function(file = "index.Rmd", dir = dirname(file), default_file = NULL,
# the theme wins out
if (length(target_file)) {
format <- output_format_from_yaml_front_matter(read_utf8(target_file))
old_theme <- shiny::getCurrentTheme()
on.exit(set_current_theme(old_theme), add = TRUE)
set_current_theme(resolve_theme(format$options$theme))
Comment on lines +144 to 146
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty sure when I originally wrote the set_current_theme() code I was thinking that since set_current_theme() uses shiny::shinyOptions(), the previous value would be automatically restored, but it actually doesn't because this call happens outside of an app/session scope (in that case, shiny::shinyOptions() is basically like setting options()).

}

Expand Down