@@ -425,26 +425,32 @@ set_chunk_attrs <- function(teal_card,
425425# ' chunk outputs of a `teal_card` based on plot dimensions from a plot widget.
426426# '
427427# ' @param pws (`plot_widget`) plot widget that provides dimensions via `dim()` method
428- # ' @param decorated_output_q (`reactive`) reactive expression that returns a `teal_card `
428+ # ' @param q_r (`reactive`) reactive expression that returns a `teal_reporter `
429429# ' @param inner_classes (`character`) classes within `chunk_output` that should be modified.
430430# ' This can be used to only change `recordedplot`, `ggplot2` or other type of objects.
431431# '
432432# ' @return A reactive expression that returns the `teal_card` with updated dimensions
433433# '
434434# ' @keywords internal
435- set_chunk_dims <- function (pws , decorated_output_q , inner_classes = NULL ) {
435+ set_chunk_dims <- function (pws , q_r , inner_classes = NULL ) {
436436 checkmate :: assert_list(pws )
437437 checkmate :: assert_names(names(pws ), must.include = " dim" )
438438 checkmate :: assert_class(pws $ dim , " reactive" )
439- checkmate :: assert_class(decorated_output_q , " reactive" )
439+ checkmate :: assert_class(q_r , " reactive" )
440440 checkmate :: assert_character(inner_classes , null.ok = TRUE )
441441
442442 reactive({
443- dims <- req(pws $ dim())
444- q <- req(decorated_output_q())
443+ pws_dim <- stats :: setNames(as.list(req(pws $ dim())), c(" width" , " height" ))
444+ if (identical(pws_dim $ width , " auto" )) { # ignore non-numeric values (such as "auto")
445+ pws_dim $ width <- NULL
446+ }
447+ if (identical(pws_dim $ height , " auto" )) { # ignore non-numeric values (such as "auto")
448+ pws_dim $ height <- NULL
449+ }
450+ q <- req(q_r())
445451 teal.reporter :: teal_card(q ) <- set_chunk_attrs(
446452 teal.reporter :: teal_card(q ),
447- list (dev.width = dims [[ 1 ]] , dev.height = dims [[ 2 ]] ),
453+ list (dev.width = pws_dim $ width , dev.height = pws_dim $ height ),
448454 inner_classes = inner_classes
449455 )
450456 q
0 commit comments